Next.js 15 is a React framework that provides server-side rendering, static site generation, API routes, and the App Router. It is widely used for production React applications. This guide sets up and deploys a Next.js 15 application on Ubuntu 26.04 LTS with Node.js 22 and Nginx.

Tested and valid on:

  • Ubuntu 26.04 LTS

Prerequisites

  • Ubuntu 26.04 LTS with Node.js 22 LTS and npm installed
  • PM2 installed globally (npm install -g pm2)
  • Nginx installed

Step 1 – Create a New Next.js 15 Application

cd /var/www
npx create-next-app@15 mynextapp --typescript --app --no-src-dir
cd mynextapp

Step 2 – Build for Production

npm run build

Step 3 – Start with PM2

pm2 start npm --name mynextapp -- start
pm2 save
pm2 startup

Step 4 – Configure Nginx as Reverse Proxy

sudo nano /etc/nginx/sites-available/mynextapp

Add:

server {
    listen 80;
    server_name example.com www.example.com;
    location /_next/static { alias /var/www/mynextapp/.next/static; }
    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}
sudo ln -s /etc/nginx/sites-available/mynextapp /etc/nginx/sites-enabled/
sudo nginx -t && sudo systemctl reload nginx

Step 5 – Add SSL with Certbot

sudo certbot --nginx -d example.com -d www.example.com

Step 6 – Set Up Environment Variables

nano /var/www/mynextapp/.env.production

Add your variables:

NEXT_PUBLIC_API_URL=https://api.example.com
DATABASE_URL=mysql://user:pass@localhost/mydb

Step 7 – Deploy Updates

cd /var/www/mynextapp
git pull
npm install
npm run build
pm2 reload mynextapp

Conclusion

Next.js 15 is deployed on Ubuntu 26.04 LTS with PM2 and Nginx. Your React application now has production-grade SSR, incremental static regeneration, and is served behind an SSL-enabled reverse proxy.