Database

Set up database connections with typed query clients, migrations, and connection pooling. Supports SQL databases, edge-compatible drivers, and managed platforms.

sqlormmigrationsqueries

Providers

PostgreSQL

Full-featured relational database with Drizzle ORM

drizzle-orm
DATABASE_URL

SQLite

Lightweight embedded database for local-first applications

better-sqlite3

Turso

Edge-hosted SQLite with libSQL replication and global distribution

@libsql/client
TURSO_DATABASE_URLTURSO_AUTH_TOKEN

Supabase

Managed PostgreSQL with real-time subscriptions, auth, and storage

@supabase/supabase-js
SUPABASE_URLSUPABASE_ANON_KEY

Usage

Query with Drizzle

Type-safe database queries using the generated client

import { db } from '@/lib/db'
import { users } from '@/lib/db/schema'
import { eq } from 'drizzle-orm'

const user = await db.query.users.findFirst({
  where: eq(users.email, '[email protected]'),
  with: { posts: true },
})

Get Started

Add database to your Primstack project with a single command:

prim db init