TL;DR: DRZL is a developer toolkit for Drizzle ORM. It analyzes your schema and generates router code (adapter‑based), typed services, and runtime validators (Zod/Valibot/ArkType). It’s template‑driven, so you can swap adapters (currently oRPC) and grow into tRPC/Express/Nest/Next.js‑style stacks with custom templates.
What is DRZL?
DRZL is an adapter‑agnostic code generation toolchain for Drizzle ORM. It consists of:
- Analyzer — normalizes your Drizzle schema into a portable Analysis that generators can consume.
-
Generators — build reusable code from the Analysis:
- Routers (adapter‑based) — currently ships with oRPC, with templates for different styles.
- Validation — Zod, Valibot, and ArkType schemas (insert/update/select) + index barrel.
- Service — typed services that can be Drizzle‑aware or stubbed.
- Templates — swap or customize router implementations (standard/minimal, oRPC + Service, or your own).
👉 Docs & examples: https://use-drzl.github.io/drzl/
Quickstart
1) Install the CLI
pnpm add -D @drzl/cli
# npm i -D @drzl/cli
# yarn add -D @drzl/cli
# bun add -d @drzl/cli
2) Add a single config (oRPC + Zod + Service)
// drzl.config.ts
import { defineConfig } from '@drzl/cli/config';
export default defineConfig({
schema: 'src/db/schemas/index.ts',
outDir: 'src/api',
generators: [
// 1) Zod validators
{ kind: 'zod', path: 'src/validators/zod', schemaSuffix: 'Schema' },
// 2) Routers (oRPC adapter), reusing Zod schemas
{
kind: 'orpc',
template: '@drzl/template-orpc-service',
includeRelations: true,
outputHeader: { enabled: true },
validation: {
useShared: true,
library: 'zod',
importPath: 'src/validators/zod',
schemaSuffix: 'Schema',
},
},
// 3) Typed services (Drizzle‑aware or stub)
{
kind: 'service',
path: 'src/services',
dataAccess: 'drizzle', // or 'stub'
dbImportPath: 'src/db/connection',
schemaImportPath: 'src/db/schemas',
},
],
});
3) Install the generators/template you reference
pnpm add -D @drzl/generator-zod @drzl/generator-service @drzl/template-orpc-service
# If you prefer Valibot or ArkType:
# pnpm add -D @drzl/generator-valibot @drzl/generator-service @drzl/template-orpc-service
# pnpm add -D @drzl/generator-arktype @drzl/generator-service @drzl/template-orpc-service
The oRPC generator ships with the CLI. Validation + Service generators are separate packages so you install only what you use.
4) Generate
pnpm drzl generate -c drzl.config.ts
# npx drzl generate -c drzl.config.ts
# yarn drzl generate -c drzl.config.ts
# bunx drzl generate -c drzl.config.ts
This writes validators to src/validators/*
, routers to src/api
, and services to src/services
.
(Optional) Watch mode
pnpm drzl watch -c drzl.config.ts --pipeline all --debounce 200
(Optional) No‑config oRPC quickstart
pnpm dlx drzl generate:orpc src/db/schemas/index.ts -o src/api --template standard --includeRelations
Adapter‑based by design
DRZL is adapter‑agnostic: router generation is driven by small, composable templates. Today it targets oRPC. You can write your own templates to target other stacks (tRPC, Express, NestJS, Next.js, Prisma, etc.), or use community/premium templates as they become available.
Key ideas:
- Templates define file paths, exported names, imports/prelude, and the code for each procedure.
- Validation reuse: generators can wire shared Zod/Valibot/ArkType schemas into handlers (inputs/outputs).
-
Typed outputs: the generator adds
.output(...)
typing where applicable.
Examples
- Relations example — relation‑aware generation patterns.
- Validation mix — reuse shared validators across routers/services.
(See the site for live examples and code.)
Licenses & ownership
- You own the generated output — use/modify/distribute under your project’s license.
- A short output header is added by default; you can disable (
outputHeader.enabled = false
) or customize it.
Roadmap & support
- More adapter templates (community + premium) for deeper integrations.
- Custom templates available as a paid service if you need a specific stack/pattern.
- DRZL is open‑core; contributions, issues, and stars are welcome.
—
Links
- Docs: https://use-drzl.github.io/drzl/
- Getting Started: https://use-drzl.github.io/drzl/guide/getting-started.html
- CLI Overview: https://use-drzl.github.io/drzl/cli.html
- Generators: oRPC, Service, Zod, Valibot, ArkType
- Templates: Standard, oRPC + Service, Custom
- Adapters: Overview & Router Adapters
If you ship something with DRZL, I’d love to see it!
Top comments (0)