How to Deploy a Next.js App in India (Server Rendering) | Replov
Skip to main content

Next.js

Deploy a Next.js app on Replov

A server-rendered Next.js app (App Router or Pages Router, with API routes, server actions or SSR) needs a running Node.js server. On Replov that is a Web Service: Replov builds your repository into a container image and runs it in its Bangalore region with a public HTTPS address.

If your app uses output: 'export' and has no server code, deploy it as a Static Site instead; it is cheaper and the first two Nano static sites have no compute charge.

Last verified against the product on .

Before you start

  • A Next.js app in a GitHub repository, with a lockfile (package-lock.json, pnpm-lock.yaml or yarn.lock) committed.
  • A working next build on your machine.
  • A Replov account with wallet balance for a paid tier (or a new service’s 3-day trial on tiers above Nano).

How Replov builds it

  • Replov detects Node.js from package.json and generates a multi-stage Dockerfile for it; you do not need to write one.
  • Replov adds output: 'standalone' to your Next.js config when it can do so safely and runs the small standalone server. If your config cannot be edited safely it is left exactly as it is and the app runs with next start. The build log says which.
  • If the service’s root directory contains its own Dockerfile, Replov builds that instead.

Deploy it

  1. 1

    Sign in to Replov and connect GitHub (Connect GitHub / Import from GitHub). Replov asks for access to the repositories you choose.

  2. 2

    Create a project for the repository, then add a service to it.

  3. 3

    Choose Service Type: Web Service, select the repository and Branch.

  4. 4

    Leave Root Directory empty for a single app. In a monorepo, set it to the app folder (for example apps/web); npm, pnpm and Yarn workspaces are supported.

  5. 5

    Leave Build Command empty to use npm run build (or set your own), and leave Start Command empty: Replov starts the Next.js server itself.

  6. 6

    Add Environment Variables, including any NEXT_PUBLIC_* values (see below).

  7. 7

    Pick the Compute Tier for this Service (Micro, 1 vCPU and 1 GB, is a reasonable start for a Next.js server) and deploy.

Example: package.json scripts

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

Environment variables and ports

  • NEXT_PUBLIC_* variables are inlined into the browser bundle at build time. Replov passes your environment variables to the build, so set them before deploying and redeploy after changing them.
  • Server-only values (database URLs, API keys) are read at runtime. Store credentials as secrets: they are encrypted and are never shown again after you save them.
  • The server listens on PORT (3000), which Replov sets; you do not configure a port.

Domains and HTTPS

Every web service and static site gets an HTTPS address of the form <service-name>-<4 characters>.replov.com once it is live.

To use your own domain, open the service, choose Connect Domain and publish the CNAME and TXT records Replov shows at your DNS provider. After verification Replov routes the hostname and issues a Let’s Encrypt certificate automatically. More on HTTPS.

Logs and monitoring

The build log streams while the deployment runs; the first failing command and the lines just above it usually explain a failed build. Runtime logs (with live streaming) and CPU, memory and network metrics are on the service page. See service logs.

Troubleshooting

A NEXT_PUBLIC_ value is undefined in the browser
It was not set when the image was built. Add it to the service’s environment variables and redeploy; changing it at runtime has no effect on the bundle.
The build runs out of memory
Next.js builds are memory-hungry. Move the service to a larger tier, or reduce build-time work such as large static generation.
Static assets 404 in a monorepo
Check that Root Directory points at the Next.js app folder, not the repository root.
The service builds but never becomes healthy
Remove any custom Start Command (for example one that runs next dev or a fixed port), and check the runtime log for an error at startup, often a missing server-side environment variable.

Deploy your repository on Replov

Connect GitHub, choose a service type and a compute tier, and watch the build log.