Skip to content
Built with

Code generation ​

SDK Reference

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.

sh
void gen model posts title:string body:text published:boolean

Example output: the CLI lists the files it created, such as the schema and a migration.

Creates:

  • db/schema/posts.ts: a table with id, createdAt, updatedAt and your columns
  • An export from db/schema.ts
  • routes/api/posts/index.ts: GET to list rows and POST to insert with validation
  • routes/api/posts/[id].ts: GET by ID, with 404 handling
  • 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.

sh
void gen migration add_avatar_to_users
# → db/migrations/20260410161500_add_avatar_to_users.sql

Example 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.

sh
void gen route api/health
void gen route api/users --methods get,post,delete

Example 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.

sh
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 with defineRender
  • src/main.client.{tsx,ts}: client entry with hydration
  • src/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.

sh
void gen cron hourly-sync

Example 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.

sh
void gen queue emails

Example output: the path of the new queue file.

Next steps ​

implemented.stream AI