{"id":20882,"library":"zenstack","title":"ZenStack","description":"ZenStack is a fullstack enhancement layer for Prisma ORM that provides seamless integration from database to UI. It extends Prisma with access policies, automatic API generation (REST and RPC), client-side hooks for React/TanStack Query, Zod schema generation, and more. Current stable version is 3.6.2, with active releases roughly every month. Key differentiators: declarative permission policies similar to Firebase Security Rules, custom types with relations, OpenAPI spec generation, and deep integration with Prisma without replacing it. Requires Prisma 5.0+ and Zod 3.25+ as peer dependencies.","status":"active","version":"2.22.1","language":"javascript","source_language":"en","source_url":"https://github.com/zenstackhq/zenstack","tags":["javascript","fullstack","react","typescript","data modeling","prisma"],"install":[{"cmd":"npm install zenstack","lang":"bash","label":"npm"},{"cmd":"yarn add zenstack","lang":"bash","label":"yarn"},{"cmd":"pnpm add zenstack","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for runtime validation of input/output schemas","package":"zod","optional":false},{"reason":"Core ORM that ZenStack extends","package":"prisma","optional":false},{"reason":"Required for policy evaluation in some contexts","package":"zod","optional":true}],"imports":[{"note":"Core enhancement function for the Prisma client. Use from @zenstackhq/runtime since v2.","wrong":"import { enhance } from 'zenstack'","symbol":"enhance","correct":"import { enhance } from '@zenstackhq/runtime'"},{"note":"React hooks are in @zenstackhq/tanstack-query since v3. The old @zenstackhq/react package is deprecated.","wrong":"import { useFindMany } from 'zenstack/react'","symbol":"useFindMany","correct":"import { useFindMany } from '@zenstackhq/tanstack-query'"},{"note":"Zod generation utilities are in @zenstackhq/zod since v3.0.","wrong":"import { generateZodSchemas } from 'zenstack'","symbol":"generateZodSchemas","correct":"import { generateZodSchemas } from '@zenstackhq/zod'"}],"quickstart":{"code":"// Install: npm install @zenstackhq/runtime @zenstackhq/tanstack-query prisma @prisma/client zod\n// Define schema.prisma with ZenStack extensions\n// model User {\n//   id        String   @id @default(uuid())\n//   email     String   @unique\n//   role      String   @default('user')\n//   posts     Post[]\n//   @@allow('read', true)\n//   @@allow('create,update', auth().role == 'admin')\n// }\n// Run: npx zenstack generate\nimport { PrismaClient } from '@prisma/client';\nimport { enhance } from '@zenstackhq/runtime';\n\nconst prisma = new PrismaClient();\nconst enhanced = enhance(prisma, { getCurrentUser: () => ({ id: '1', role: 'admin' }) });\n\nasync function main() {\n  const users = await enhanced.user.findMany();\n  console.log(users);\n}\nmain()","lang":"typescript","description":"Shows how to set up a ZenStack-enhanced Prisma client with a permissive policy for reading users."},"warnings":[{"fix":"Update imports: use @zenstackhq/tanstack-query instead of @zenstackhq/react.","message":"Since v3, React hooks moved from @zenstackhq/react to @zenstackhq/tanstack-query","severity":"breaking","affected_versions":">=3.0.0 <3.0.0"},{"fix":"Change 'import { generateZodSchemas } from \"zenstack\"' to 'import { generateZodSchemas } from \"@zenstackhq/zod\"'.","message":"Zod schema generation now requires explicit import from @zenstackhq/zod","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Replace imports with specific @zenstackhq/* packages.","message":"The old 'zenstack' global package is deprecated; use scoped packages like @zenstackhq/runtime, @zenstackhq/tanstack-query","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Use @@allow and @@deny with auth() conditions; test policies thoroughly.","message":"Policy rules must be defined correctly; incorrect rules may silently return empty results","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install @zenstackhq/runtime'.","cause":"Missing installation of the runtime package.","error":"Cannot find module '@zenstackhq/runtime' or its corresponding type declarations."},{"fix":"Use 'import { enhance } from \"@zenstackhq/runtime\"'; then call 'enhance(prisma, { getCurrentUser })'.","cause":"Using enhance incorrectly or missing import.","error":"TypeError: prismadb.enhance is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}