# Create a PostgreSQL database and connect your app

Source: https://resilis.io/docs/postgresql/create-and-connect/

Creating a database takes a few choices: where it lives, which engine version, how big, and who can reach it. This page walks through them, then binds the connection to your app and covers pooling, public access, external databases and frameworks.

## Create a database

Open the new database page in the dashboard. Creation runs in four steps: Engine, Configure, Network and Review. In Configure you pick the environment, a database name and the storage size, and you choose a region and the CPU and memory the database gets. Review shows the choices before anything is created.

Create the database in the project and environment your app uses, and place the app and database in the same region, so the internal address resolves.

## Choose a version and extensions

The recommended default is PostgreSQL 17. The creation form offers PostgreSQL 14 to 18, and available versions depend on the selected target. Pick the version your app was tested against.

For PostgreSQL you can start from a preset: pgvector for embeddings, PostGIS for geospatial data, TimescaleDB for time series, Citus for sharding, or pgvector with PostGIS. Presets are not offered on every version, and none is offered on PostgreSQL 18. A list of common extensions, such as pg_trgm and uuid-ossp, can be added too.

## Keep the database private

In the Network step, public network access is off by default and only apps within the project can connect. Keep it off whenever your app can use the internal connection. If you turn it on, you list the IP ranges allowed to connect.

Storage can be expanded later but not reduced, so start with what you need.

## Bind the connection to your app

Resilis binds the database connection to your app as a sensitive environment variable. DATABASE_URL is the default name, and you can use whichever name your app reads. Keep the value out of source control, prompts, logs, terminal history and screenshots.

Read the variable on the server only, then deploy and create and read a disposable record to prove the connection works.

### TypeScript

```ts
// lib/db.ts
import { Pool } from 'pg';

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

- [Node.js and PostgreSQL walkthrough](/guides/nodejs-postgresql/)

## Is my database reachable from the internet?

Not if you keep public access disabled, which is what Resilis recommends whenever your app can use an internal connection. The app connects over the internal address, and the connection value is bound as a sensitive environment variable.

The app has to run where it can reach the internal endpoint, and an internal address in one environment may not resolve from another.

## Do I need connection pooling?

It depends on how many connections your app opens. Many app instances, or code that opens a connection per request, can use up a database’s connections.

Resilis includes connection pooling with managed databases, so you do not have to add a separate pooler in front of one. The pooler can be configured with its mode and number of replicas.

## Can I bring an existing database or connect an external one?

Your app can connect to an external database or backend, such as Supabase or Convex, through its own connection settings. Those services are not Resilis-managed databases, so Resilis snapshots and point-in-time recovery apply only to supported databases that Resilis manages.

Connecting an existing storage bucket works differently: it registers the bucket but does not migrate objects.

- [Managed PostgreSQL and MySQL documentation](/docs/managed-data/)

## Can I use it with Next.js or NestJS?

Yes. Resilis runs the container your build produces, from Railpack or your Dockerfile, and the database connection arrives as an environment variable. In Next.js, read DATABASE_URL on the server only and never give a secret the NEXT_PUBLIC_ prefix. In NestJS, keep TypeORM’s synchronize off and run migrations as a release command.

The two guides walk through each setup. Test your exact framework versions in a development environment first.

- [Next.js with PostgreSQL in three environments](/guides/nextjs-postgresql-environments/)
- [NestJS with PostgreSQL from Claude Code](/guides/nestjs-postgresql-claude-code/)

## Can a small agency keep each client’s database separate?

Yes. Create a project per client. Each project has development, staging and production, and each environment has its own databases and secrets, so one client’s change cannot land in another client’s production.

Membership applies to the whole organization. If a client needs to see their own dashboard, give them a separate organization that holds only their project. Hobby allows 5 projects and Pro allows 10.

- [Hosting client apps for agencies](/guides/agency-client-app-hosting/)
