Prisma

Configure Prisma with `@vitehub/db/prisma`, generated client output, and native Prisma migrations.

Prisma works well when you want Prisma Client, Prisma schema tooling, and prisma migrate while still using ViteHub for integration wiring. ViteHub keeps Prisma on its native workflow and exposes the generated client through @vitehub/db/prisma.

Install Prisma

Install @vitehub/db, prisma, @prisma/client, and the adapter package that matches your runtime.

Terminal
pnpm add https://pkg.pr.new/vite-hub/vitehub/@vitehub/db@main prisma @prisma/client @prisma/adapter-pg

Configure Prisma

Set db.orm to prisma, choose a dialect, and point db.prisma.clientOutput at the generated client directory you want ViteHub to expose.

nuxt.config.ts
export default defineNuxtConfig({
  modules: ['@vitehub/db/nuxt'],
  db: {
    orm: 'prisma',
    dialect: 'postgresql',
    connection: {
      url: process.env.DATABASE_URL,
    },
    prisma: {
      schemaPath: 'prisma/schema.prisma',
      clientOutput: '.vitehub/db/prisma-client',
    },
  },
})

Configure the Prisma generator

Use the Prisma 7 prisma-client generator and keep the output path aligned with db.prisma.clientOutput.

prisma/schema.prisma
generator client {
  provider               = "prisma-client"
  output                 = "../.vitehub/db/prisma-client"
  moduleFormat           = "esm"
  generatedFileExtension = "js"
  importFileExtension    = "js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

The generator output must match db.prisma.clientOutput. If those paths drift, @vitehub/db/prisma cannot load the generated client you expect.

Query with @vitehub/db/prisma

Import the generated Prisma runtime from @vitehub/db/prisma.

server/api/users.get.ts
import { prisma } from '@vitehub/db/prisma'

export default defineEventHandler(async () => {
  return await prisma.user.findMany()
})

Prisma options

db.prisma controls where Prisma files live and how ViteHub resolves the generated client.

KeyPurpose
schemaPathPoints to the Prisma schema file.
configPathPoints to prisma.config.ts when you use one.
clientOutputPoints to the generated Prisma client directory.
engineTypeControls the Prisma engine mode.

Run native Prisma commands

Prisma owns client generation and migration authoring. ViteHub only runs the committed migration flow for you during development and build.

Terminal
pnpm prisma generate
pnpm prisma migrate dev
pnpm prisma migrate deploy
Prisma on Cloudflare D1 is not supported in this iteration. Use Drizzle when you need D1 bindings.