brizzle
v0.3.0
Published
Rails-like generators for Next.js + Drizzle ORM projects
Maintainers
Readme
Rails-like generators for Next.js + Drizzle ORM projects. Generate models, server actions, CRUD pages, and API routes with a single command.
Installation
npm install -g brizzleOr use with npx:
npx brizzle scaffold post title:string body:textQuick Start
# Initialize Drizzle ORM in your project
npx brizzle init
# Generate a full CRUD scaffold (model + actions + pages)
brizzle scaffold post title:string body:text published:boolean
# Generate just model and actions (no views)
brizzle resource user name:string email:string:unique
# Generate model and REST API routes
brizzle api product name:string price:float
# Generate only a model
brizzle model comment content:text authorId:references:user
# Generate only actions for an existing model
brizzle actions postCommands
brizzle init
Interactive setup wizard for Drizzle ORM. Configures your database connection and generates all necessary files.
brizzle initSupports:
- SQLite: better-sqlite3, libsql (Turso), bun:sqlite
- PostgreSQL: postgres.js, pg, neon, vercel-postgres
- MySQL: mysql2, planetscale
Options:
--dialect <dialect>- Database dialect for non-interactive mode--driver <driver>- Database driver for non-interactive mode--no-install- Skip automatic dependency installation
brizzle model <name> [fields...]
Creates a Drizzle schema model in db/schema.ts.
brizzle model user name:string email:string:unique
brizzle model post title:string body:text published:boolean
brizzle model order total:decimal status:enum:pending,paid,shippedbrizzle actions <name>
Creates server actions file with CRUD operations.
brizzle actions userbrizzle resource <name> [fields...]
Creates model + actions (no UI pages).
brizzle resource session token:uuid userId:references:user --uuidbrizzle scaffold <name> [fields...]
Creates model + actions + full CRUD pages (list, show, new, edit).
brizzle scaffold product name:string price:float description:text?brizzle api <name> [fields...]
Creates model + REST API route handlers.
brizzle api webhook url:string secret:string:uniquebrizzle destroy <type> <name>
Removes generated files (does not modify schema).
brizzle destroy scaffold post
brizzle destroy api product --dry-runbrizzle config
Shows detected project configuration.
Field Types
| Type | SQLite | PostgreSQL | MySQL |
|------|--------|------------|-------|
| string | text | text | varchar(255) |
| text | text | text | text |
| integer / int | integer | integer | int |
| bigint | integer | bigint | bigint |
| boolean / bool | integer (mode: boolean) | boolean | boolean |
| float | real | doublePrecision | double |
| decimal | text | numeric | decimal |
| datetime / timestamp | integer (mode: timestamp) | timestamp | datetime |
| date | integer (mode: timestamp) | date | date |
| json | text | jsonb | json |
| uuid | text | uuid | varchar(36) |
Special Types
enum:status:enum:draft,published,archivedreferences:authorId:references:user
Field Modifiers
Nullable: Add
?to make field optionalbrizzle model user bio:text? nickname?Unique: Add
:uniquemodifierbrizzle model user email:string:unique
Options
| Option | Description |
|--------|-------------|
| -f, --force | Overwrite existing files |
| -n, --dry-run | Preview changes without writing |
| -u, --uuid | Use UUID for primary key |
| --no-timestamps | Skip createdAt/updatedAt fields |
Auto-Detection
The generator automatically detects your project configuration:
- Project structure:
src/app/vsapp/ - Path aliases: Reads from
tsconfig.json(@/,~/, etc.) - Database dialect: Reads from
drizzle.config.ts - DB location: Checks
db/,lib/db/,server/db/
Run brizzle config to see detected settings.
Example Output
$ brizzle scaffold post title:string body:text published:boolean
Scaffolding Post...
create db/schema.ts
create app/posts/actions.ts
create app/posts/page.tsx
create app/posts/new/page.tsx
create app/posts/[id]/page.tsx
create app/posts/[id]/edit/page.tsx
Next steps:
1. Run 'pnpm db:push' to update the database
2. Run 'pnpm dev' and visit /postsRequirements
- Node.js >= 18
- Next.js project with App Router
- Drizzle ORM configured (or run
brizzle initto set it up)
Roadmap
- [x] Drizzle init -
brizzle initto set up Drizzle ORM, database config, and db connection - [ ] Authentication -
brizzle authto generate better-auth setup with user model and sign-in/sign-up pages - [ ] Zod schemas - Generate validation schemas for forms and API routes
- [ ] Indexes - Support for
name:string:indexfield modifier - [ ] Default values - Support for
status:string:default:active - [ ] Soft deletes - Add
--soft-deleteflag fordeletedAttimestamp - [ ] Pagination - Add pagination to list pages and API routes
- [ ] Search & filtering - Generate search/filter UI for list pages
- [ ] Seed generator -
brizzle seed <model>to generate seed data files - [ ] Relations helper - Better syntax for has-many/belongs-to relationships
- [ ] Custom templates - Allow overriding templates via
.brizzle/directory - [ ] Interactive mode -
brizzle newwizard for step-by-step model creation - [ ] Import cleanup - Remove unused imports when destroying models
Have a feature request? Open an issue
License
MIT
