Deployment

How to Deploy a Next.js App on ComputeSphere

P
By Peter Ekhator

Next.js gives you server rendering, the App Router, and API routes in one framework. Putting it in production, though, usually means a platform that bills per seat and per build — or hand-rolled infrastructure you have to keep patched. ComputeSphere runs your Next.js app as a container on a fixed per-spherelet price, so you get full SSR without the per-seat tax or the ops work.

This guide takes a Next.js app to a live HTTPS URL, then adds environment variables, a custom domain, and autoscaling.

Before you start

  • A Next.js app (App Router or Pages Router)
  • Docker installed locally
  • A free ComputeSphere account — the trial runs 14 days, no card required

Install the csph CLI

brew install computesphere/tap/csph
# or
npm install -g @computesphere/csph

Then sign in:

csph auth login

Configure Next.js for a container

Set output: "standalone" in next.config.js. Next then emits a minimal, self-contained server you can run anywhere:

const nextConfig = { output: "standalone" };
module.exports = nextConfig;

Containerize your app

A multi-stage Dockerfile keeps the final image small:

FROM node:22-slim AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

FROM node:22-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/public ./public
EXPOSE 3000
CMD ["node", "server.js"]

Deploy

From your project directory:

csph deploy

ComputeSphere builds the image, runs it on a spherelet, terminates TLS, and returns a public URL:

https://teal-otter.computesphere.app

Already have an image in a registry? Deploy it directly with csph deploy --image <ref>. Connect your GitHub repo once and every push ships a new version with a zero-downtime cutover.

Set environment variables

Next.js has two kinds of config. NEXT_PUBLIC_* values are baked in at build time; server-only secrets are read at runtime:

csph services set-env NEXT_PUBLIC_API_URL=https://api.example.com
csph services set-secret DATABASE_URL=postgres://user:pass@host:5432/db

Set build-time public variables before you build; set runtime secrets on the service.

Add a custom domain

Open Console → Domains, add your hostname, and create the CNAME it shows pointing to your service URL:

Type    Name    Value
CNAME   www     teal-otter.computesphere.app

ComputeSphere issues and auto-renews the SSL certificate — no Cloudflare config, no cert files.

Scale with spherelets

SSR scales well horizontally, and a spherelet is your unit of compute. Pick a size (Flex, Standard, or Performance), run as many spherelets as your traffic needs, and turn on autoscaling with a minimum, a maximum, and a target CPU. You pay a fixed price per spherelet — no per-seat fees, so a traffic spike doesn't turn into a surprise invoice.

Wrap-up

A Next.js app with full SSR reaches production on ComputeSphere in one command: set output: "standalone", containerize, and run csph deploy. You get HTTPS, custom domains, and autoscaling on pricing you can predict.

Ready to ship? Start your free trial or book a 15-minute demo.

Predictable cloud, from your first push.

Fixed price per spherelet, flat plan per team — ship without DevOps or surprise bills.

Start free trial

14-day free trial

Share this article

Ship your next service on ComputeSphere

Predictable per-spherelet pricing, a flat plan per team, and managed primitives built in — no DevOps, no surprise bills.

Deploy your first spherelet in minutes.

Connect a repo or start from a template — live URL, SSL, and zero DevOps, on predictable per-spherelet pricing. 14-day free trial.