npm install get-dbimport { instantPostgres } from 'get-db'; export async function createDatabase() { const { databaseUrl, poolerUrl, claimUrl } = await instantPostgres({ seed: { type: 'sql-script', path: './init.sql', } }); return({ databaseUrl, poolerUrl , claimUrl }); }
Create a new ephemeral Postgres database. Pass a ref to identify the source.
curl -X POST https://pg.new/api/v1/database \ -H "Content-Type: application/json" \ -d '{"ref": "my-app"}'
| Field | Type | Description |
|---|---|---|
| status | string | Database status (UNCLAIMED, CLAIMING, or CLAIMED) |
| neon_project_id | string | The Neon project identifier |
| connection_string | string | PostgreSQL connection URI |
| claim_url | string | URL to claim the database |
| expires_at | string | ISO 8601 expiration timestamp |