Code generation
These commands create starter code for you: models, migrations, routes, middleware and more.
On this pageGenerate a model and its migration · Scaffold a route or middleware · Add custom SSR
void gen model
void gen model <name> [columns...]Creates a Drizzle table, list and create routes, and a route that fetches one row by ID. Now you will generate a posts model.
void gen model posts title:string body:text published:booleanExample output: the CLI lists the files it created, such as the schema and a migration.
Creates:
db/schema/posts.ts: a table withid,createdAt,updatedAtand your columns- An export from
db/schema.ts routes/api/posts/index.ts:GETto list rows andPOSTto insert with validationroutes/api/posts/[id].ts:GETby ID, with404handling- Fresh types and TypeScript config in
.void/
The routes detect your validation library from package.json: valibot, zod or arktype. If none is found, the CLI asks you to pick one or skip validation. Next, run void db push to apply the schema locally. Or run void db generate to create migrations before you deploy.
Column format: name:type, or name:type? for a nullable column. Types: string, text, datetime, integer, boolean, real, blob.
Model names use lowercase letters, digits and underscores, such as posts or user_roles. Existing files are never overwritten.
void gen migration
void gen migration <name>Creates an empty migration file with a timestamp prefix (YYYYMMDDHHMMSS). Now you will generate one.
void gen migration add_avatar_to_users
# → db/migrations/20260410161500_add_avatar_to_users.sqlExample output: the path of the new SQL file in db/migrations/.
Projects that use the old number prefix (0001_, 0002_, ...) can rename files with void db rename-migrations.
void gen route
void gen route <path> [--methods get,post,...]Creates a route file with defineHandler exports. The default method is GET. Now you will generate two routes.
void gen route api/health
void gen route api/users --methods get,post,deleteExample output: the path of the new route file.
The file is routes/<path>.ts, with one exported handler per method. Supported methods are get, post, put, patch and delete.
void gen middleware
void gen middleware <name>Creates a numbered middleware file with a defineMiddleware default export. Now you will generate an auth middleware.
void gen middleware auth
# → middleware/01.auth.ts (or 02, 03, etc.)Example output: the path of the new middleware file.
The number prefix follows your existing middleware files.
void gen ssr
void gen ssr [--react | --vue | --svelte | --solid]Creates SSR entry points and a minimal App component for your framework.
Creates three files:
src/main.ssr.{tsx,ts}: server entry withdefineRendersrc/main.client.{tsx,ts}: client entry with hydrationsrc/App.{tsx,vue,svelte}: minimal interactive component
Without a flag, the CLI detects the framework from package.json dependencies.
void gen cron
void gen cron <name>Creates a cron job file in crons/ with defineScheduled and a placeholder schedule. Now you will generate one.
void gen cron hourly-syncExample output: the path of the new cron file.
void gen queue
void gen queue <name>Creates a queue consumer in queues/ with defineQueue, a Message type and commented-out batch options. Now you will generate one.
void gen queue emailsExample output: the path of the new queue file.