Registry / database / drizzle-zero

drizzle-zero

JSON →
library0.18.0jsnpmunverified

Generates Zero schemas from Drizzle ORM table definitions, enabling local-first sync via Zero. Current version 0.18.0 requires drizzle-orm >=0.36.0 and @rocicorp/zero. Automatically maps Drizzle column types to Zero schema types, handling primary keys, references, and indexes. Useful for projects using PostgreSQL with local-first sync without manual schema translation.

npm install drizzle-zero
INSTALL
IMPORT
SIG · DRIZZLE-ZERO
D
drizzle-zero
databasejavascriptv0.18.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

drizzleZeroSchema
import { drizzleZeroSchema } from 'drizzle-zero'
const { drizzleZeroSchema } = require('drizzle-zero')
Package is ESM-only; CommonJS require will not work. Use named export.
toZeroSchema
import { toZeroSchema } from 'drizzle-zero'
Alternatively named export available in v0.18.0.
type DrizzleZeroSchema
import type { DrizzleZeroSchema } from 'drizzle-zero'
import { DrizzleZeroSchema } from 'drizzle-zero'
DrizzleZeroSchema is a TypeScript type, not a value. Must use type-only import.

Define Drizzle schema for users table, then generate Zero schema using drizzleZeroSchema.

import { drizzle } from 'drizzle-orm/node-postgres'; import { pgTable, serial, text, integer, timestamp } from 'drizzle-orm/pg-core'; import { drizzleZeroSchema } from 'drizzle-zero'; // Define your Drizzle schema const users = pgTable('users', { id: serial('id').primaryKey(), name: text('name').notNull(), age: integer('age'), createdAt: timestamp('created_at').defaultNow(), }); const db = drizzle(process.env.DATABASE_URL ?? ''); // Generate Zero schema const zeroSchema = drizzleZeroSchema({ db, schema: { users } }); console.log(zeroSchema);
Debug
Known issues
gotchadrizzle-zero requires drizzle-orm >=0.36.0 and @rocicorp/zero as peer dependencies. Missing these will cause runtime errors.
fix
Install required peer deps: npm install drizzle-orm@>=0.36.0 @rocicorp/zero
affects: >=0.1.0
gotchaThe package is ESM-only. Using CommonJS require() will throw an error.
fix
Use import syntax or set type: module in package.json.
affects: >=0.1.0
gotchadrizzleZeroSchema expects a schema object keyed by table names, not a list of tables. Providing an array will cause unexpected results.
fix
Pass schema as an object: { users, posts } instead of [users, posts].
affects: >=0.1.0
breakingIn v0.18.0, the function signature changed from generateZeroSchema to drizzleZeroSchema. Old code using generateZeroSchema will break.
fix
Replace generateZeroSchema with drizzleZeroSchema and update parameters.
affects: <0.18.0
Errors
Common errors & fixes
Error: Cannot find module 'drizzle-zero'
Package not installed or not in node_modules.
fix
npm install drizzle-zero
TypeError: drizzleZeroSchema is not a function
CommonJS require used instead of ES import, or incorrect named import.
fix
Use import { drizzleZeroSchema } from 'drizzle-zero'
Error: generateZeroSchema is not defined
Breaking change in v0.18.0 renamed the function.
fix
Use drizzleZeroSchema instead of generateZeroSchema.
Upgrade
Version history
0.18.0latest on npm
Audit
Dependencies
drizzle-ormrequiredRequired peer dependency for Drizzle schema definitions
@rocicorp/zerorequiredRequired peer dependency for Zero schema output
prettieroptionalOptional peer dependency for formatting generated schema
Agent activity
65 hits · last 30 days
node
34
Bingbot
27
Resources
drizzle-zero — npm install drizzle-zero · libregistry