Skip to main content
Version: 1.x

Installing ZenStack

You can install ZenStack to your project using one of the following methods.

Using zenstack init

The easiest way to install ZenStack is to use the zenstack init command. In an existing TypeScript project folder, run the following command:

npx zenstack@1 init

The "init" command does the following things for you:

  1. Install Prisma if it's not already installed.
  2. Install the zenstack CLI package as a dev dependency.
  3. Install the @zenstackhq/runtime package - used for enhancing PrismaClient at the runtime.
  4. Copy the prisma/schema.prisma file to schema.zmodel if it exists; otherwise, create a new template schema.zmodel file.

You can always manually complete the steps above if you have a special project setup that the "init" command doesn't work with.

After the initialization, please remember that you should edit the schema.zmodel moving forward. The prisma/schema.prisma file will be automatically regenerated when you run zenstack generate.

Manually

The following steps show how to install using "npm" as package manager. Replace it with the one you use for your project (like pnpm or yarn).

  1. Make sure Prisma is installed

  2. Install the zenstack CLI package as a dev dependency

    npm install --save-dev zenstack@1
  3. Install the @zenstackhq/runtime package as a regular dependency

    npm install @zenstackhq/runtime@1
  4. Bootstrap ZModel from Prisma schema

    If you have a Prisma schema file, copy it to schema.zmodel in the project root folder. Remember, you should edit the schema.zmodel moving forward. The prisma/schema.prisma file will automatically regenerate when you run zenstack generate.

Comments
Feel free to ask questions, give feedback, or report issues.

Don't Spam


You can edit/delete your comments by going directly to the discussion, clicking on the 'comments' link below