You can install ZenStack to your project using one of the following methods.
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@latest init
The "init" command does the following things for you:
- Install Prisma if it's not already installed.
- Install the
zenstackCLI package as a dev dependency.
- Install the
@zenstackhq/runtimepackage - used for enhancing
PrismaClientat the runtime.
- Copy the
schema.zmodelif it exists; otherwise, create a new template
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
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).
Make sure Prisma is installed
zenstackCLI package as a dev dependency
npm install --save-dev zenstack@latest
@zenstackhq/runtimepackage as a regular dependency
npm install @zenstackhq/runtime@latest
Bootstrap ZModel from Prisma schema
If you have a Prisma schema file, copy it to
schema.zmodelin the project root folder. Remember, you should edit the
schema.zmodelmoving forward. The
prisma/schema.prismafile will automatically regenerate when you run