Qo'llanma7 min read·22-aprel, 2026

How to Deploy a Next.js App on if.uz — Step-by-Step Guide

Deploy your Next.js 14/15 application to if.uz in under 5 minutes. Covers App Router, environment variables, custom domains, and Postgres setup.

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:

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:

json
{
  "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

  1. 1Log in to if.uz and click "Deploy new app"
  2. 2Select your GitHub repo
  3. 3Choose your branch (main or production)
  4. 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:

bash
# 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

  1. 1Go to Marketplace in your dashboard
  2. 2Click "Deploy" next to PostgreSQL
  3. 3Wait ~30 seconds for the database to start
  4. 4Copy the internal connection string from the Connection Details panel
  5. 5Add it as DATABASE_URL in your app's environment variables
  6. 6Redeploy your app
bash
# Example DATABASE_URL from if.uz Marketplace Postgres
DATABASE_URL=postgresql://postgres:[email protected]:5432/mydb

Step 6 — Custom Domain (Pro Plan)

  1. 1Upgrade to Pro in the dashboard (Settings → Plan)
  2. 2Go to Settings → Custom Domain
  3. 3Enter your domain (e.g. myapp.company.uz)
  4. 4Add a CNAME record pointing to if.uz at your DNS provider
  5. 5SSL is provisioned automatically — no Certbot needed

Common Issues and Fixes

IssueFix
Port not bindingEnsure your app uses process.env.PORT — Next.js standalone does this automatically
Build fails: cannot find moduleCheck 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 varRemember 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.

Deploy qilishga tayyormisiz?

Bepul plan, kredit karta kerak emas, 2 daqiqada jonli.

Bepul boshlash →