logoComputeSphere
Deployment

How to Deploy a Next.js App on ComputeSphere

P
By Peter Ekhator
•3 min read•

A Next.js app with full server rendering reaches a live HTTPS URL on ComputeSphere with one command, csph deploy, after one config change: output: "standalone". This guide makes that change, containerizes the app and deploys it, then adds environment variables, a custom domain and autoscaling. You pay per spherelet, not per seat or per build.

Before you start

  • A Next.js app (App Router or Pages Router)
  • Docker installed locally
  • A ComputeSphere account — a 14-day trial; a card is required to start, and you're charged from day 15 unless you cancel

Install the csph CLI

brew install computesphere/cli/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 variables set NEXT_PUBLIC_API_URL=https://api.example.com --service <service-id> --environment <environment-id>
csph services secrets set DATABASE_URL="$DATABASE_URL" --service <service-id> --environment <environment-id>

csph services list shows the service id and csph environments list the environment id.

Set DATABASE_URL in your shell first, for example from a file or your password manager, so the secret itself never appears in the command or your shell history.

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 Plus), 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, with no per-seat fees, and every plan includes data out each month (10 GB to 1,000 GB, by plan), so you know what compute costs as traffic grows. Autoscaling is a Team plan feature; on Hobby and Pro you set the spherelet count yourself.

Your app is in production

Your Next.js app now runs on ComputeSphere with full SSR, HTTPS, its config in variables and secrets, and your own domain.

Next step: get started and run csph deploy from your project, 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 app in minutes.

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