Next.js is the most popular React framework in the world, and if.uz supports it out of the box via Nixpacks. This guide walks you through deploying a Next.js app — including App Router, API routes, and server-side rendering — to if.uz.
Prerequisites
- A Next.js project pushed to a GitHub repository
- An if.uz account (free — no card needed)
- Node.js 18+ (Nixpacks detects this from your package.json engines field)
Step 1 — Configure next.config.js
For Next.js to run correctly on if.uz, set the output mode to standalone. This produces a self-contained build that runs with just node server.js:
// next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
output: 'standalone',
}
module.exports = nextConfig⚠️ Warning
Without output: "standalone", the Next.js build requires the full node_modules directory to run — making the deployment image much larger. Standalone mode cuts image size by 80%.
Step 2 — Set the Start Command
Add a start script to your package.json that runs the standalone server:
{
"name": "my-nextjs-app",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "node .next/standalone/server.js"
},
"engines": {
"node": ">=18"
}
}Step 3 — Deploy on if.uz
- 1Log in to if.uz and click "Deploy new app"
- 2Select your GitHub repo
- 3Choose your branch (main or production)
- 4Click Deploy
Nixpacks detects Next.js, runs npm run build, then starts the server. Your app will be live at yourapp-username.if.uz in about 2 minutes.
Step 4 — Environment Variables
Add your environment variables in the dashboard under Settings → Environment Variables. For Next.js, remember the distinction between server-side and client-side variables:
# Server-side only (not exposed to browser)
DATABASE_URL=postgresql://...
NEXTAUTH_SECRET=your-secret
STRIPE_SECRET_KEY=sk_live_...
# Client-side (must start with NEXT_PUBLIC_)
NEXT_PUBLIC_API_URL=https://myapp-username.if.uz
NEXT_PUBLIC_GA_ID=G-XXXXXXXXXXℹ️ Info
NEXT_PUBLIC_ variables are baked into the build. If you change them, you need to redeploy — not just restart. Click "Redeploy" in the dashboard after updating public env vars.
Step 5 — Adding a Postgres Database
- 1Go to Marketplace in your dashboard
- 2Click "Deploy" next to PostgreSQL
- 3Wait ~30 seconds for the database to start
- 4Copy the internal connection string from the Connection Details panel
- 5Add it as DATABASE_URL in your app's environment variables
- 6Redeploy your app
# Example DATABASE_URL from if.uz Marketplace Postgres
DATABASE_URL=postgresql://postgres:[email protected]:5432/mydbStep 6 — Custom Domain (Pro Plan)
- 1Upgrade to Pro in the dashboard (Settings → Plan)
- 2Go to Settings → Custom Domain
- 3Enter your domain (e.g. myapp.company.uz)
- 4Add a CNAME record pointing to if.uz at your DNS provider
- 5SSL is provisioned automatically — no Certbot needed
Common Issues and Fixes
| Issue | Fix |
|---|---|
| Port not binding | Ensure your app uses process.env.PORT — Next.js standalone does this automatically |
| Build fails: cannot find module | Check that all dependencies are in "dependencies" not "devDependencies" for runtime modules |
| Images not loading (next/image) | Add your image domains to next.config.js remotePatterns |
| 500 error on env var | Remember NEXT_PUBLIC_ vars need a redeploy, not just restart |
Next.js on if.uz is production-ready from day one. Start with the free plan for development and staging, then upgrade to Pro when you're ready to attach a custom domain and go live.