Articles

Host Next.js 16 and PostgreSQL outside Vercel without DevOps

Deploy Next.js 16 Server Components, Route Handlers and Server Actions with automatic standalone sizing (~40 MB), bundled managed PostgreSQL on Hobby ($10/mo), PR previews and 5xx canary rollbacks.

Updated

Host Next.js 16 with managed PostgreSQL outside Vercel on a platform that runs your app as a real Node server inside an isolated Firecracker microVM and bundles managed Postgres in the same plan. On Gregale, gregale deploy automatically builds plain next start apps with output: "standalone", shrinks a ~530 MB Next.js tree down to roughly 40 MB so it fits Free and Hobby, injects managed PostgreSQL as DATABASE_URL on Hobby ($10 a month), pauses compute ~1 second after idle requests, and rolls back 5xx releases automatically.

Why run Next.js as a Node server with bundled Postgres

Serverless function hosts give you edge caching and zero-config Next.js builds, but Server Components, Route Handlers, background work and database connections often force extra adapters:

  • Full Next.js runtime parity. Gregale runs next build and next start in a real Linux microVM, so Server Components, Route Handlers, Server Actions, Middleware and long-lived connections work without serverless wrappers.
  • Automatic standalone sizing. When package.json uses a plain next start command, Gregale builds with output: "standalone" (Applying modifyConfig from gregale-standalone) and ships .next/standalone with .next/static and public (~40 MB instead of ~530 MB with full node_modules). That keeps builds well under Free's 256 MB app-layer cap.
  • Bundled Postgres without add-on sprawl. On Hobby ($10 a month for up to 5 apps with 512 MB RAM and 200 GB-RAM-hours included), gregale add postgres provisions managed PostgreSQL in one network namespace and binds DATABASE_URL directly.

Quick start and health checks

Keep the standard create-next-app scripts in package.json:

json
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}

Add a lightweight health route and register it in gregale.yaml:

ts
// app/healthz/route.ts
export function GET() {
  return Response.json({ ok: true });
}
yaml
# gregale.yaml
hosting:
  health: /healthz

Then deploy directly or test our reference Next.js 16 + Postgres starter in one click:

bash
gregale deploy --dry-run
gregale deploy --name my-next-app
gregale add postgres --app my-next-app

How alternatives compare for Next.js + Postgres

PlatformFree backend / Next serverCheapest paid + PostgresIdle billing behaviorReleases & rollbacks
GregaleFree: 1 app, 256 MB, 20 GB-RAM-hrsHobby $10/mo + PG includedPauses ~1s after last requestDefault 1%→10%→50%→100% 5xx canary + DB PITR
VercelHobby: non-commercial onlyPro $20/seat/mo + PG addonFluid Compute scales functions between requestsRolling releases & instant rollback (code only)
Render750 hrs (spins down 15m idle)Starter $7/mo + PG $6/moPaid web services bill continuouslyCached-build rollback + manual DB restore
Railway$1 monthly usage creditHobby $5/mo + metered DBServerless sleeps after idle timeoutDeployment rollback + sibling DB restore
Fly.io$5/mo allowance (up to 3 VMs)~$2.19/mo VM + Managed PGMachines auto-stop/start on trafficImage redeploy + separate DB cluster restore

Stay on Vercel when your workload is primarily static/ISR pages backed by global edge middleware across 300+ PoPs. Move to Gregale when you run full-stack Next.js APIs and Server Actions closely coupled to PostgreSQL and want predictable spend caps, free PR preview environments and automatic 5xx canary rollbacks. See Gregale vs Vercel, Deploy a Next.js app, and starter templates.

Questions

Does Next.js 16 fit inside Gregale Free with standalone builds?

Yes. When package.json uses a plain next start script, Gregale enables standalone output and ships only the standalone bundle (~40 MB instead of ~530 MB), fitting Free’s 256 MB app-layer limit.

Do Server Components and Server Actions work without serverless adapters?

Yes. Gregale runs Next.js as a full Node process inside an isolated Firecracker microVM, so Server Components, Route Handlers, Middleware and Postgres connection pools work out of the box.

Can I bundle managed PostgreSQL with Next.js on Gregale?

Yes. Managed PostgreSQL is included on Hobby ($10 a month) and higher plans, wired automatically as DATABASE_URL with optional point-in-time rollback alongside app releases.