Postgres
Add a serverless PostgreSQL database to your project.
npx extraorbital add neonUse the pooled connection for app queries. Use the direct connection for migrations.
- 01 / Run the commandGet the service
- 02 / Read your .envUse its credentials
- 03 / Connect your appCall the SDK or API
Limits
| Limit | Free · Prototype | Paid |
|---|---|---|
| Databases | 1 | No plan count cap |
| Storage | From the $5.00 account allowance | Usage billed |
| Compute | Scales to zero when idle | Usage billed; scales to zero |
| Bandwidth | 500 GB / mo per database | $0.10 / GB past 500 GB |
| Backups | None | Charged as storage |
| Inactive resource | 30 days after last use | Persistent |
Free allowances are shared across the account. Provider limits still apply on paid plans.
Use it
For queries from a serverless function:
import { neon } from "@neondatabase/serverless";
const sql = neon(process.env.POSTGRES_URL!);
const [{ now }] = await sql`select now()`;Environment variables
The CLI writes these to .env or an existing .env.local.
| Variable | Purpose |
|---|---|
POSTGRES_URL | Pooled connection for app queries |
POSTGRES_URL_NON_POOLING | Direct connection for migrations |
POSTGRES_HOST | Database hostname |
POSTGRES_USER | Database user |
POSTGRES_PASSWORD | Database password |
POSTGRES_DATABASE | Database name |
Specifics
Options
npx extraorbital add postgres [--slug <name>] [--region <region>]| Flag | Default | Description |
|---|---|---|
--slug | default | A second, fully separate database in the same project |
--region | us-east-1 | Where the project lives. A Neon region id like aws-eu-central-1 also works |
Options apply at creation. Re-running add with different options returns the
existing database unchanged.
Connections
Use POSTGRES_URL_NON_POOLING for migrations. postgres, pg, and neon are aliases. The resource address is neon/default.
Detection
The CLI detects POSTGRES_* names. It does not use DATABASE_URL because that name does not identify a provider. Ambiguous variables require a choice.
Idle databases
Compute stops after five idle minutes. Storage continues to consume credit.
Pricing
| Usage | Paid rate |
|---|---|
| Storage | $0.35 / GB-mo |
| Compute | $0.106 / CU-hour |
| Bandwidth | $0.10 / GB past 500 GB |
See pricing for team subscription fees, allowances, and billing terms. Plans and billing ↗
Restore history costs $0.20/GB-month. Storage is charged while idle.