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@latest init
The "init" command does the following things for you:
- Install Prisma if it's not already installed.
- Install the
zenstack
CLI package as a dev dependency. - Install the
@zenstackhq/runtime
package - used for enhancingPrismaClient
at the runtime. - Copy the
prisma/schema.prisma
file toschema.zmodel
if it exists; otherwise, create a new templateschema.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).
-
Make sure Prisma is installed
-
Install the
zenstack
CLI package as a dev dependencynpm install --save-dev zenstack@latest
-
Install the
@zenstackhq/runtime
package as a regular dependencynpm install @zenstackhq/runtime@latest
-
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 theschema.zmodel
moving forward. Theprisma/schema.prisma
file will automatically regenerate when you runzenstack generate
.