Skip to content

Next.js + PostgreSQL

The Next.js + PostgreSQL template deploys a full-stack web application with a database, ready for production use.

What’s included

ServiceImage/SourcePort
WebYour Next.js repository3000
PostgreSQLpostgres:165432

How it works

When you deploy this template:

  1. PostgreSQL is created with auto-generated credentials and persistent storage
  2. Your Next.js app is cloned from GitHub, built, and deployed
  3. DATABASE_URL is automatically injected into your web service
  4. Both services are connected via private networking

Your Next.js app can immediately query the database without any manual configuration:

import { Pool } from 'pg';
const pool = new Pool({
connectionString: process.env.DATABASE_URL,
});
const result = await pool.query('SELECT NOW()');

Deploying

  1. Go to Templates → Next.js + PostgreSQL
  2. Enter your GitHub repository URL
  3. Select the branch to deploy
  4. Click Deploy

Your app will be live within a few minutes at your-project.your-org.stackpad.eu.

Customizing

After deployment, you can:

  • Add environment variables for your app
  • Configure a custom domain
  • Add Redis for caching
  • Set up preview deployments for pull requests

For the best deployment performance, add standalone output to your next.config.js:

/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
};
export default nextConfig;

This creates a minimal production bundle that starts faster and uses less memory.

What’s next?