V3 is currently in alpha phase and not ready for production use. Feedback and bug reports are greatly appreciated. Please visit this dedicated discord channel for chat and support.
ZenStack is a TypeScript database toolkit for developing full-stack or backend Node.js/Bun applications. It provides a unified data modeling and access solution with the following features:
- A modern schema-first ORM that's compatible with Prisma's schema and API
- Versatile data access APIs: high-level (Prisma-style) ORM queries + low-level (Kysely) query builder
- Built-in access control and data validation (coming soon)
- Advanced data modeling patterns like polymorphism
- Designed for extensibility and flexibility: plugins, life-cycle hooks, etc.
- Automatic CRUD web APIs with adapters for popular frameworks (coming soon)
- Automatic TanStack Query hooks for easy CRUD from the frontend (coming soon)
ZenStack V3 is a major rewrite of V2. The biggest change is V3 doesn't have a runtime dependency to Prisma anymore. Instead of working as a big wrapper of Prisma as in V2, V3 made a bold move and implemented the entire ORM engine using Kysely, while keeping the query API fully compatible with Prisma.
Please check this blog post for why we made this big architectural change decision.
Even without using advanced features, ZenStack offers the following benefits as a drop-in replacement to Prisma:
- Pure TypeScript implementation without any Rust/WASM components.
- More TypeScript type inference, less code generation.
- Fully-typed query-builder API as a better escape hatch compared to Prisma's raw queries or typed SQL.
Although ZenStack v3's runtime doesn't depend on Prisma anymore (specifically,
@prisma/client
), it still relies on Prisma to handle database migration. See database migration for more details.
You can also check the blog sample for a complete example.
Use the following command to scaffold a simple TypeScript command line application with ZenStack configured:
npm create zenstack@next my-project
Or, if you have an existing project, use the CLI to initialize it:
npx @zenstackhq/cli@next init
Alternatively, you can set it up manually:
npm install -D @zenstackhq/cli@next
npm install @zenstackhq/runtime@next
Then create a zenstack
folder and a schema.zmodel
file in it.
Please visit the doc site for detailed documentation.