Neon Postgres

Serverless Postgres. Connected via the Neon HTTP driver — no persistent socket, fits Functions cold-start model.

Client

src/lib/db/index.ts:

import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";

const sql = neon(process.env.DATABASE_URL!);
export const db = drizzle(sql, { schema });

Connection string

Set DATABASE_URL to a Neon pooled connection string (ends in -pooler.<region>.aws.neon.tech).

Schema

Source in src/lib/db/schema/*.ts, all re-exported from schema/index.ts. See ../database/schema.md.

Migrations

drizzle-kit — see ../database/migrations.md.

Transactions

Neon HTTP driver does not support multi-statement transactions across separate queries — single statement only. Code that needs atomicity (e.g. registration insert-three-rows) currently runs sequentially without a transaction. For cross-row atomicity, swap to neon-serverless (WebSocket-based) or postgres-js via pooler.

Branching

Neon branches are first-class. Useful patterns:

  • Preview branches per PR — isolate schema changes.
  • Shadow branch for local dev — so db:push doesn't affect prod.