Getting Started
Installation
Install Corsair in your Next.js + Drizzle + Postgres project
Installation
Prerequisites
- Node.js 18 or higher
- Existing database (PostgreSQL)
- ORM: Prisma or Drizzle
Install Corsair
npm install corsair
# or
pnpm add corsair
# or
yarn add corsairInitialize Corsair
Run the CLI to set up Corsair in your project:
npx corsair initThis will:
- Detect your database schema
- Configure your ORM integration (if applicable)
- Set up the Corsair client
- Generate TypeScript types
Configuration
The init command creates a corsair.config.ts file:
import { defineConfig } from 'corsair'
export default defineConfig({
database: {
type: 'postgresql',
url: process.env.DATABASE_URL,
},
orm: 'prisma', // or 'drizzle' or 'none'
output: './src/lib/corsair',
})Init Options
# Specify ORM
npx corsair init --orm prisma
# Skip interactive prompts
npx corsair init --yes
# Specify database type
npx corsair init --db postgresqlEnvironment Variables
Add your database URL to your .env file:
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"