Neon
Using Neon PostgreSQL with Quickback Stack. Connection modes, Drizzle integration, and Neon Authorize setup.
Neon provides serverless PostgreSQL that works with Cloudflare Workers via HTTP connections. Choose Neon when you need PostgreSQL features (JSON operators, full-text search, advanced indexing) or database-level Row Level Security.
Configuration
import { defineConfig, defineRuntime, defineDatabase, defineAuth } from "@quickback/compiler";
export default defineConfig({
name: "my-app",
providers: {
runtime: defineRuntime("cloudflare"),
database: defineDatabase("neon", {
connectionMode: "auto",
pooled: true,
}),
auth: defineAuth("better-auth"),
},
});Connection Modes
| Mode | Best For | How It Works |
|---|---|---|
| HTTP | Cloudflare Workers, edge functions | Stateless HTTP queries via @neondatabase/serverless |
| WebSocket | Node.js, Bun | Persistent WebSocket connection for lower latency |
| Auto (default) | Mixed environments | Detects runtime and picks the best mode |
Environment Variables
Set your Neon connection string as a secret:
# For Cloudflare Workers
npx wrangler secret put DATABASE_URL
# Paste your Neon connection string: postgresql://user:pass@ep-xxx.region.neon.tech/dbname
# For local development (.env)
DATABASE_URL=postgresql://user:pass@ep-xxx.region.neon.tech/dbnameMigrations
Neon uses PostgreSQL migrations (different from D1's SQLite migrations):
# Generate migrations after compiling
quickback compile
# Apply migrations
npm run db:migrateWhen to Choose Neon vs D1
| Factor | Neon | D1 |
|---|---|---|
| SQL dialect | PostgreSQL | SQLite |
| Security model | RLS + application-layer | Application-layer only |
| Multi-region | Built-in replication | Single region per database |
| Pricing | Free tier, then usage-based | Free tier, then usage-based |
| Best for | Complex queries, existing Postgres apps | Edge-first, simple schemas |
See Also
- Neon Integration — Complete setup guide with RLS policy details
- D1 — Alternative: SQLite at the edge
- Providers — All database provider options