Corsair
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 corsair

Initialize Corsair

Run the CLI to set up Corsair in your project:

npx corsair init

This 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:

corsair.config.ts
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 postgresql

Environment Variables

Add your database URL to your .env file:

.env
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"