# Kysely + Neon: pick the dialect for your transaction needs

## The trap
Kysely tutorials for Neon use `NeonDialect` from `kysely-neon` backed by the `neon()` HTTP client. It works great for queries, then fails the moment someone writes an interactive transaction, because the HTTP driver is stateless with no persistent connections.

## The rule (from Neon's Kysely guide)
- HTTP driver (`NeonDialect` + `neon()`): serverless-friendly, one-shot queries only.
- Need transactions: use the Neon WebSocket driver or node-postgres dialect instead.

```ts
import { Kysely } from 'kysely';
import { NeonDialect } from 'kysely-neon';
import { neon } from '@neondatabase/serverless';

export const db = new Kysely[Database]({
  dialect: new NeonDialect({ neon: neon(process.env.DATABASE_URL) }),
});
```

## Checklist
- Audit for `.transaction()` usage before choosing the HTTP dialect.
- Migrations run against the direct connection string.
- Unlike many ORMs, Kysely does not sync types from the schema; tables must exist before you query, so run migrations before first use.
- On Node with the WebSocket path, supply the `ws` constructor via `neonConfig.webSocketConstructor`.