Prisma
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.
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.
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.
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.
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.
| Key | Purpose |
|---|---|
schemaPath | Points to the Prisma schema file. |
configPath | Points to prisma.config.ts when you use one. |
clientOutput | Points to the generated Prisma client directory. |
engineType | Controls 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.
pnpm prisma generate
pnpm prisma migrate dev
pnpm prisma migrate deploy