Generate type-safe SQLite table schemas from Zod validation schemas, v1.0.2. Requires Node >=24.4.0 and Zod v4 as a peer dependency. Provides a single createTable() function that produces SQL CREATE TABLE and INDEX statements plus a Zod object schema for runtime validation and TypeScript inference. Key differentiators: single source of truth for both database schema and validation, automatic CHECK constraints from Zod rules (min/max, enums, literals), foreign key support, and index management. Released as a new tool bridging Zod and SQLite, with active development.
npm install zod-sqliteNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates creating a users table with primary key, unique index, and automatic CHECK constraints from Zod validators.
Upgrade Node to >=24.4.0 or use an older major version of the package.
Install zod@^4.0.0 alongside this package.
Wrap default values in arrow functions: z.date().default(() => new Date())
Use .safeParse() for error handling. No special treatment needed.
Use snake_case or camelCase without spaces. Sanitize names before passing.
Change to import { createTable } from 'zod-sqlite' or use dynamic import().Run: npm install zod@^4.0.0
Use .default(() => new Date()) in Zod v4.