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:
- Install Prisma if it's not already installed.
- Install the
zenstackCLI package as a dev dependency. - Install the
@zenstackhq/runtimepackage - used for enhancingPrismaClientat the runtime. - Copy the
prisma/schema.prismafile toschema.zmodelif it exists; otherwise, create a new templateschema.zmodelfile.
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).
-
Make sure Prisma is installed
-
Install the
zenstackCLI package as a dev dependencynpm install --save-dev zenstack@1 -
Install the
@zenstackhq/runtimepackage as a regular dependencynpm install @zenstackhq/runtime@1 -
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 theschema.zmodelmoving forward. Theprisma/schema.prismafile will automatically regenerate when you runzenstack generate.