Skip to content
Next.js+Postgres on Vercel
Stack Integration

Next.js + Postgres on Vercel

Vercel Postgres is no longer available for new projects. Connect a PostgreSQL provider through the Vercel Marketplace, then query it from Next.js server code.

Check current platform documentation ↗
Use Cases
  1. Relational data for a Next.js app deployed on Vercel
  2. Server-side queries in Server Components and Route Handlers
  3. Separate database credentials for preview and production deployments
  4. Migrations and connection pooling configured for your chosen provider
Implementation

Choose a Postgres provider in the Vercel Marketplace and follow its current integration instructions. Keep the connection string server-only. Use that provider's supported driver or a compatible Postgres client in Server Components and Route Handlers; select a pooled connection for short-lived serverless requests if the provider offers one. Run migrations with the provider's recommended direct connection or migration workflow.

In detail

What changed with Vercel Postgres

Vercel no longer offers Vercel Postgres for new projects. The current path is to choose a PostgreSQL provider from the Vercel Marketplace and connect it to your project. Existing projects using the older integration may have different environment variables and migration steps. Check the provider's documentation before changing a live database. This page keeps its original URL so older links reach the corrected guidance.

How the pieces connect

The request reaches a Next.js Server Component or Route Handler. Server-side code opens a connection using the selected provider's driver or a compatible Postgres client, runs a parameterized query and returns only the data the interface needs. The database URL stays in server-only environment variables. The exact variable names, pooling behavior and preview-branch support depend on the provider you choose; they are not universal Vercel features.

Production gotchas

Short-lived serverless functions can create many database connections at once. Check whether your provider supplies a pooler and use the connection path it recommends for application queries. Migrations may need a direct connection or a provider-specific workflow. Give preview deployments separate credentials or database branches where available so test writes do not hit production. Keep queries parameterized and set caching behavior deliberately for data that must reflect recent writes.

When this setup fits

This approach fits when your Next.js app needs relational queries and you already deploy on Vercel. Compare providers on region, connection limits, branching, backups, price and migration support before choosing. If you need a particular Postgres extension or long-running connection, verify provider support rather than assuming the Marketplace integration supplies it.

Setup checklist

  1. Select a current PostgreSQL provider in the Vercel Marketplace and read its Next.js connection guide.
  2. Connect the provider to the correct Vercel project and environments.
  3. Add its supported driver; read credentials only in server code.
  4. Use parameterized queries and the provider's recommended pooler if needed.
  5. Run migrations using the provider's documented workflow.
  6. Test a preview deployment against isolated data, then verify production credentials and backups.
Other integration guidesView all →
Related

Need this built?

Email Dusko about a project

For a project enquiry, include what you’re building, its current stage and your target date.