Skip to content

Next.js provider

The nextjs provider targets Next.js 16 with the App Router. It is the richest Codabra target: models, API routes, functions, events, voters and views are all rendered, with Drizzle or Prisma persistence.

Generated file mapping

ConfigurationGenerated output
models/User.jsonsrc/types/User.ts and the ORM schema
routes/Users.jsonGET /api/userssrc/app/api/users/route.ts
routes/Users.jsonGET /api/users/:idsrc/app/api/users/[id]/route.ts
views/LoginPage.json/loginsrc/app/login/page.tsx
functions/CreateUser.jsonsrc/lib/functions/CreateUser.ts
voters/ArticleVoter.jsonsrc/lib/voters/ArticleVoter.ts

Dynamic App Router parameters are generated using the asynchronous Next.js 16 contract: route handlers await params before reading an identifier.

Persistence

Choose the ORM and database independently in codabra.json:

json
{
  "providers": [
    {
      "provider": "nextjs",
      "orm": "drizzle",
      "database": "postgresql"
    }
  ]
}

Supported combinations are:

ORMSQLitePostgreSQLMySQL
Drizzleyesyesyes
Prismayesyesyes

For Drizzle, Codabra generates src/drizzle/schema.ts and src/lib/db.ts. For Prisma, it generates prisma/schema.prisma and src/lib/prisma.ts.

Then apply the schema through the provider-aware CLI:

bash
codabra db push --provider nextjs

Set DATABASE_URL in apps/nextjs/.env.local when the selected database needs a connection string. Projects created before the multi-provider layout may keep using apps/web; Codabra still detects that legacy directory.

Development and build

bash
codabra dev --provider nextjs
codabra build --provider nextjs

The default development port is 3000. Override it with --port.

Released under the Elastic License 2.0.