Put a Next.js app online on its own HTTPS address, with a real PostgreSQL database beside it and VS Code in the browser, on a free plan. Ours was running in about two minutes, with the PostgreSQL driver already installed and the connection string waiting in the environment.
What you get on the free plan
One app with one database: 2 GB of memory and 2 GB of disk, VS Code in the browser and a terminal in the same container as the app, its own HTTPS address from the first minute, SSH from your own editor if you prefer it, and nightly backups. No card, no time limit.
Create the app: Next.js and PostgreSQL
Stacks, Create, Blank stack. Search for "next" and pick Next.js, then add PostgreSQL: it is connected to the app automatically. Give the app a name; PostgreSQL fills in its own database name and generates a password if you leave it empty.
Deploy
Press Deploy, check the summary, then Confirm and deploy. Ours was live in 126 seconds the first time and 130 the second: Next.js installs its packages on the first start. The stack page has the app's address, VS Code, the web terminal and the database in one place.
The database is already wired in
The app gets the whole connection as DATABASE_URL, and the parts as POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER and POSTGRES_PASSWORD, so no password sits in your code. The PostgreSQL driver for Node (pg) is installed when the app starts, and the app runs as next dev, so saving a file updates the page.
A first API route on PostgreSQL
Create app/api/notes/route.js and paste this in. It creates a notes table the first time it is used and answers GET and POST on /api/notes. We ran exactly this on a fresh app: two POSTs, then a GET that returned both notes.
import pg from 'pg'; const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL }); const ready = pool.query('CREATE TABLE IF NOT EXISTS notes (id serial PRIMARY KEY, text text NOT NULL)'); export async function GET() { await ready; const { rows } = await pool.query('SELECT id, text FROM notes ORDER BY id'); return Response.json(rows); } export async function POST(request) { await ready; const { text } = await request.json(); const { rows } = await pool.query('INSERT INTO notes (text) VALUES ($1) RETURNING id, text', [text]); return Response.json(rows[0], { status: 201 }); } Does Next.js fit in 2 GB?
For a starter app, with room to spare. Over two hours of editing and reloading, the Next.js container (dev server and VS Code together) went from 588 to 612 MB, PostgreSQL stayed around 25 MB, and the stack page showed 0.79 GB of the 2 GB.
The full guide, with every screenshot and the bring-your-own-repo steps: https://portal.uppcoder.com/guides/deploy-nextjs-postgresql?utm_source=devto&utm_medium=blog&utm_campaign=posts&utm_content=post-229




