Skip to main content
Reliant hosting serves Next.js two ways, and you pick by what the app uses. A static export (output: "export") is a folder of HTML and JS on the free static hosting and CDN. An app that needs a server at request time (server actions, middleware, route handlers that answer dynamically, cookies(), ISR, next/image optimization) runs as a container built from its Dockerfile, like any other backend. This guide covers both. It was run at Forge v1.10.1-0.20261123064811-54313eead62f.

Before you begin

  • Node.js, and the app in a git repository.
  • Forge: reliant forge inside Reliant, or npx -y @reliantlabs/forge@latest anywhere else.
  • Static: nothing to pay (one hosted static site per person is free). Server: a Reliant account with app hosting billing.

Path 1: a static export

Set the export in next.config.mjs:
next.config.mjs
next build then writes out/, which is what Forge publishes. Every route is rendered at build time, so a dynamic segment like app/posts/[slug]/page.js needs a generateStaticParams() listing every slug. When the values exist only at runtime (records in your API), move the id into the query string: /posts/view?slug=…, read with useSearchParams.
1

Adopt and lint

terminal
The lint names everything the export refuses, with its file and line, before next build does. On our test app:
Output (trimmed)
Fix each finding until the lint passes, then npm run build, which is the authority.
2

Deploy

Signed in:
terminal
With no account, npx -y @reliantlabs/forge@latest env deploy prod --claimable adopts the app if needed and publishes it, with a claim link valid for 72 hours. See Deploy without an account.
3

Verify

terminal
An unknown path with no extension falls back to index.html (200), a missing file with an extension is 404.

Path 2: a Next.js server, from its Dockerfile

If the lint reports server actions, middleware or cookies(), and removing them isn’t an option, deploy the app as a service. Forge’s lint says this itself when the config isn’t an export: “a Next.js server is a process, so it ships as a workload”. Use Next’s standalone output and a Dockerfile:
Dockerfile
with output: "standalone" in next.config.mjs. HOSTNAME=0.0.0.0 matters: the standalone server otherwise binds the container’s hostname only. Then adopt it as an app, not a site:
terminal
Output (trimmed)
Write the files without --dry-run, then docker build ., reliant forge env render prod, and reliant forge env deploy prod --yes. Without billing it is queued, exit 7, with the billing link. A Next server needs more than the anonymous plan’s 128 MiB, so deploy it signed in. Verify with reliant forge env status prod, a curl of a server-rendered page, and reliant forge obs check prod --wait --json (exit 0 proven good, 1 regressed, 2 not proven, 8 the wait ran out; without OpenTelemetry it is 2, not proven good). Don’t adopt a server app with --kind site: it is accepted, but every env then fails lint --static-export with static-export-not-exported and env render refuses the binding.

Next.js gotchas

  • next/image without unoptimized fails the export: there is no image server.
  • NEXT_PUBLIC_* is baked into the build, and public. Per-env values that must change without a rebuild go in runtime_config (served as /config.js); see Deploy a static site.
  • Route handlers (app/api/*/route.ts) are allowed in an export only as GET with export const dynamic = "force-static".
See also: Adopt an existing Vite or Next.js app, Deploy Express, Hosting limits.