All docs

Databases

PostgreSQL

Managed PostgreSQL with automatic backups and point-in-time recovery.

Creating a database

Add PostgreSQL to your project from the dashboard or CLI:

bash
compos database create --type postgresql --name my-db

The database is provisioned into the same project as your application, with the same access rules. A `DATABASE_URL` environment variable is added to the project so your app can connect.

Connecting

Use the standard PostgreSQL connection string:

ts
import { Pool } from "pg";

const pool = new Pool({
  connectionString: process.env.DATABASE_URL,
});

What you get

  • **Backups**: Automatic snapshots with point-in-time recovery
  • **Connection pooling**: Managed pooling so your app holds the connection counts it should
  • **Extensions**: The commonly used PostgreSQL extensions are available on request