Skip to content

Next.js Project: Build and Deploy a Bilingual English and Arabic Site with a Standalone Build

NeedMyTools Academy

Sign in free to read the full lesson

Sign in or create a free account

Free forever. No card, no paywall.

A site on your laptop helps nobody. This project takes the bilingual Souq Guide from lesson 6, adds what a public site needs, a sitemap that links both languages, robots.txt and a production domain set through an environment variable, and then builds it into a small folder that runs on any server with Node.js. We did every step with Next.js 16.4.6 and Node.js 22 and copied the real output: the build table, the server log, the HTML of the Arabic page and the sizes on disk. We also caught one surprise that trips up many teams in their first deployment: a value you change after the build does not reach pages that were prerendered.

Quick answer

To deploy a Next.js 16 app to your own server, set output: "standalone" in next.config.ts, run npm run build with the production environment variables, copy .next/static (and public, if you have one) into .next/standalone, and start it with node server.js from that folder, choosing the port with PORT. Put a reverse proxy such as Caddy or Nginx in front for HTTPS, and keep it running with systemd, pm2 or a container. Platforms such as Vercel, Netlify and Cloudflare build it for you from Git.

60 min read and practice · Content checked on 26 November 2026

In this lesson you will

  • Read the production domain from an environment variable and know when it is fixed
  • Generate a sitemap with hreflang alternates for both languages
  • Build a standalone folder and run it with node server.js
  • Check a deployment with curl before you tell anyone it is live

Step 1: the domain comes from the environment

In lessons 5 and 6 the domain was written into the code. A real project runs in several places, your laptop, a preview server and production, so read it from an environment variable instead. lib/site.ts exports SITE_URL with a local fallback, and the layout, sitemap and robots file all import it. Variables without the NEXT_PUBLIC_ prefix stay on the server; with the prefix, Next.js copies the value into the JavaScript sent to browsers, so never put a secret in a NEXT_PUBLIC_ variable.

Locally you can keep values in .env.local, which create-next-app already lists in .gitignore, so it never reaches Git. On the server you set them in the environment of the build and of the process. For the build log in this lesson we ran npm run build with SITE_URL set to https://souq-guide.example.

Example: The site URL in one place
lib/site.ts
export const SITE_URL = process.env.SITE_URL ?? "http://localhost:3000";
app/[lang]/layout.tsx (the changed lines)
import { SITE_URL } from "@/lib/site";

  return {
    metadataBase: new URL(SITE_URL),
    title: { template: `%s | ${dict.site}`, default: dict.site },
    alternates: { languages: { en: "/en", ar: "/ar", "x-default": "/en" } },
  };
app/robots.ts
import type { MetadataRoute } from "next";
import { SITE_URL } from "@/lib/site";

export default function robots(): MetadataRoute.Robots {
  return {
    rules: { userAgent: "*", allow: "/", disallow: "/api/" },
    sitemap: `${SITE_URL}/sitemap.xml`,
  };
}
Real output: curl http://localhost:3000/robots.txt
User-Agent: *
Allow: /
Disallow: /api/

Sitemap: https://souq-guide.example/sitemap.xml

Sign in free to read the full lesson

You are reading the free preview. Create a free account (it takes one minute, no password) to unlock the rest of this lesson and track your progress.

Unlocks after sign-in:

  • 4 more sections with live code examples
  • Common mistakes to avoid
  • Hands-on coding exercise with automatic checks
  • Practice quiz and the graded lesson test
Sign in or create a free account

Free forever. No card, no paywall.

Questions people ask

Is Vercel the only way to host Next.js?

No. The official docs say a Node.js server supports every feature, and any VPS or container host can run one, as in this project. Vercel, Netlify, Cloudflare and others add Git deploys and a CDN, through their own builds or adapters.

How much does it cost to host a small Next.js site?

Many platforms have a free tier that is enough for a personal or small business site, and a small VPS costs a few dollars a month. Prices and limits change, so check the current plan pages before you choose.

What is the difference between next start and node server.js?

next start runs the production server from a full project with node_modules. node server.js is the minimal server inside .next/standalone, made by output: "standalone", which needs only that folder plus the copied static files.

Can I host a Next.js site on shared cPanel hosting?

Only if the plan can run a Node.js application, which some do through a Node.js app manager. If it serves only PHP and static files, you can upload a static export instead, but route handlers, proxy.ts and streaming will not work.

What should I learn after this Next.js course?

Pick one real project and finish it: a site for a local business, a menu or a booking page. Then learn a database with an ORM, authentication and Server Actions for forms, which build directly on the server components and route handlers from this course.

Sources

Facts in this lesson were checked against these official pages on 26 November 2026.

Code examples stay in English and run in a sandbox on your device. If you spot a mistake, tell us through the contact page.