Skip to content

TypeScript ORM and more. Schema-first, Prisma-compatibility, built-in access control, automatic CRUD API, and other goodies. V3 is an ongoing major rewrite of V2.

License

Notifications You must be signed in to change notification settings

zenstackhq/zenstack-v3

Repository files navigation

ZenStack V3

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.

What's ZenStack

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)

What's new with V3

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:

  1. Pure TypeScript implementation without any Rust/WASM components.
  2. More TypeScript type inference, less code generation.
  3. 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.

Quick start

You can also check the blog sample for a complete example.

Installation

1. Creating a new project

Use the following command to scaffold a simple TypeScript command line application with ZenStack configured:

npm create zenstack@next my-project

2. Setting up an existing project

Or, if you have an existing project, use the CLI to initialize it:

npx @zenstackhq/cli@next init

3. Manual setup

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.

Documentation

Please visit the doc site for detailed documentation.

About

TypeScript ORM and more. Schema-first, Prisma-compatibility, built-in access control, automatic CRUD API, and other goodies. V3 is an ongoing major rewrite of V2.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 6