# How to Deploy a Next.js App on Netlify (2026) - Complete Guide

> Deploy a Next.js app on Netlify in 2026. Learn what works, what breaks, and why Kuberns is a smarter alternative for full-stack Next.js apps.
- **Author**: manav-dobariya
- **Published**: 2026-05-02
- **Modified**: 2026-05-02
- **Category**: Deployment Guides
- **URL**: https://kuberns.com/blogs/deploy-nextjs-on-netlify/

---

Netlify is one of the first platforms developers think of for Next.js deployments. It connects to GitHub, builds automatically on push, and gets you a live URL fast. For a static Next.js site or a lightweight marketing page, it is a solid choice.

But Next.js in 2026 is rarely just static. Most teams are using the App Router, Server Components, API routes, ISR, and WebSocket connections. This is where Netlify's serverless model starts to show its cracks.

This guide covers how to deploy a Next.js app on Netlify step by step, exactly what breaks and why, and how [Kuberns](https://kuberns.com/) handles full-stack Next.js without the limitations.

## Prerequisites: Prepare Your Next.js App for Netlify

These steps take less than five minutes and prevent the most common Netlify deployment failures.

### 1. Make Sure Your Build Script is Correct

Netlify runs `next build` to build your app. Make sure your `package.json` has the correct scripts:

```json
{
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start"
  }
}
```

### 2. Check Your next.config.js

Netlify deploys Next.js through its own plugin (`@netlify/plugin-nextjs`). Most standard `next.config.js` settings are supported, but some output modes require attention.

If you have set `output: 'export'` in your config, Netlify treats your app as a fully static site. SSR and API routes will not work. Remove the export output if you need server-rendered pages.

```js
// next.config.js
const nextConfig = {
  // Do NOT set output: 'export' if you need SSR or API routes
};

module.exports = nextConfig;
```

### 3. Know Which Environment Variables You Need

Next.js has two types of environment variables:

- `NEXT_PUBLIC_` prefixed variables are exposed to the browser and baked in at build time
- All other variables are server-side only and injected at runtime

Both types must be added in Netlify's **Environment Variables** settings before the build runs. Variables added after a build do not take effect until you trigger a new deploy.

### 4. Push Your Code to GitHub

Netlify deploys from your repository. Push your latest changes:

```bash
git add .
git commit -m "Prepare for Netlify deployment"
git push origin main
```

That is the complete prerequisite list. No CLI to install, no config file to write beyond your existing Next.js setup.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/CTA_banner.png" alt="Deploy your Next.js app on Kuberns instead" style={{ width: "100%", height: "auto" }} />
</a>

## How to Deploy a Next.js App on Netlify (Step by Step)

### Step 1: Create a Netlify Account

![Netlify homepage](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/netlify-homepage.png)

Go to [netlify.com](https://netlify.com) and sign up. You can log in with your GitHub account to make the next step faster.

### Step 2: Import Your Repository

![Netlify dashboard](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/netlify-dashboard.png)

In the Netlify dashboard, click **Add New Site** and select **Import an Existing Project**. Choose GitHub as your Git provider and authorize Netlify to access your repositories. Select the repository that contains your Next.js app.

### Step 3: Configure Build Settings

Netlify usually auto-detects Next.js and pre-fills the build settings. Verify these are correct:

| Setting | Value |
|---|---|
| Build command | `next build` |
| Publish directory | `.next` |
| Node version | 20 (set in Environment Variables as `NODE_VERSION=20`) |

Netlify installs the `@netlify/plugin-nextjs` plugin automatically when it detects a Next.js project. This plugin is what handles SSR, ISR, and API routes on Netlify's infrastructure.

> **On [Kuberns](https://kuberns.com/), none of this configuration exists.** You do not specify a build command, a publish directory, a Node version, or install any plugin. The agentic AI reads your repository, detects Next.js from your `package.json`, and configures everything automatically. Connect your repo, add environment variables, and click Deploy.

### Step 4: Add Environment Variables

In **Site Settings > Environment Variables**, add all the variables your app needs before the first deploy.

For a typical Next.js app:

| Variable | Description |
|---|---|
| `DATABASE_URL` | Your database connection string |
| `NEXTAUTH_SECRET` | For NextAuth.js authentication |
| `NEXTAUTH_URL` | Your production domain |
| `NEXT_PUBLIC_API_URL` | Any public-facing API base URL |

Remember: `NEXT_PUBLIC_` variables are baked into the JavaScript bundle at build time. If you change them, you need to trigger a new deploy for them to take effect.

### Step 5: Deploy

Click **Deploy Site**. Netlify runs `npm install`, then `next build`, and deploys the output. Your app gets a `netlify.app` subdomain. The first build typically takes 2 to 4 minutes.

Every future push to the connected branch triggers an automatic redeploy.

## What Works Well on Netlify for Next.js

Netlify handles these Next.js use cases reliably:

- **Static pages and SSG**: Pages with `getStaticProps` or the App Router with fully static routes serve from Netlify's CDN with excellent performance
- **Simple API routes**: Short-lived API routes that complete in under 10 seconds work without issues
- **Automatic CI/CD**: Git push to deploy works smoothly, including branch previews on pull requests
- **Custom domains**: Free SSL certificates with automatic renewal on all plans

## Where Netlify Breaks for Next.js

![Netlify limitations](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/netlify-limitations.png)

This is where many developers get surprised after deploying to Netlify. The limitations are real and they show up in production.

**Serverless function timeouts cut off long-running routes.** Netlify API routes run as serverless functions with a 10-second timeout on the free plan and 26 seconds on paid plans. If your API route calls an AI model, processes a file, sends emails through a queue, or does anything that takes longer than the limit, it fails with a 502 error. There is no way to extend this timeout.

**Cold starts slow down SSR pages.** When an SSR page has not been rendered recently, the serverless function handling that render needs to initialize before responding. Users see a delay on the first request. This is not a Netlify-specific flaw, it is inherent to the serverless execution model, but it is a real performance problem for SSR-heavy Next.js apps.

**WebSockets are not supported.** Netlify does not support persistent connections. Any Next.js feature that relies on WebSockets, such as real-time updates, chat, or live collaboration, requires an entirely separate infrastructure solution.

**Image Optimization runs through serverless functions.** Netlify routes `next/image` optimization through functions, which adds latency and counts against your function execution quota. On high-traffic sites, this becomes both a performance problem and a billing problem.

**App Router streaming has inconsistent behavior.** React Server Components with streaming and Suspense boundaries do not behave identically on Netlify's runtime compared to a dedicated Node.js server. Some patterns that work locally or on a native server break on Netlify.

![Netlify problems](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/netlify-problems.png)

These are not edge cases developers only encounter at scale. Cold starts affect any SSR route. The function timeout affects any API route that does real work. WebSocket limitations affect any Next.js app with real-time features.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner6.png" alt="Deploy your Next.js app on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## The Better Way: Deploy Your Next.js App on Kuberns

![Kuberns homepage](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/kuberns-homepage.png)

[Kuberns](https://kuberns.com/) is an agentic AI deployment platform built on AWS. It runs your Next.js app as a persistent Node.js server, which means full App Router support, no function timeouts, no cold starts, WebSocket support, and Image Optimization that runs natively without hitting a serverless execution limit.

### Step 1: Create Your Kuberns Account

Go to [kuberns.com](https://kuberns.com/) and sign up. New accounts get free credits. No credit card needed to start.

### Step 2: Connect Your GitHub Repository

![Connect GitHub to Kuberns](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/kuberns-registration.png)

On the **Creating a Service** page, connect your GitHub account and select your Next.js repository and branch.

Kuberns AI scans your project and detects Next.js from your `package.json` automatically. No build command configuration required. No plugin to install.

### Step 3: Add Environment Variables

![Environment variables on Kuberns](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/environment-variable-kuberns.png)

Add your `DATABASE_URL`, `NEXTAUTH_SECRET`, `NEXTAUTH_URL`, and any other secrets in the Environment tab. Click **Add Env Vars** to add individually or **Upload .env file** to import all at once.

All values are encrypted at rest and never exposed in build logs.

### Step 4: Click Deploy

![Kuberns AI deploying app](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/kuberns-ai-deploying.png)

Click **Deploy**. Kuberns agentic AI handles everything:

- Installs all dependencies with `npm install`
- Runs `next build` to compile your app
- Starts your Next.js server with `next start` as a persistent process
- Provisions AWS compute in your chosen region
- Issues an SSL certificate and assigns a live HTTPS URL
- Enables monitoring, logging, and AI-driven auto-scaling
- Sets up CI/CD for every future push to the connected branch

### Step 5: Your Next.js App is Live

![Kuberns deployment dashboard](https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deployed-dashboard.png)

Your full-stack Next.js app is live in under five minutes with a persistent server backing it. SSR, API routes, WebSockets, and Image Optimization all work exactly as they do in your local development environment.

## Netlify vs Kuberns: Next.js Deployment Comparison

| Feature | Netlify | Kuberns |
|---|---|---|
| Runtime model | Serverless functions | Persistent Node.js server |
| SSR support | Yes, via plugin | Yes, native |
| App Router support | Partial, inconsistencies | Full support |
| API route timeout | 10s free / 26s paid | No timeout |
| Cold starts | Yes | No |
| WebSocket support | No | Yes |
| Image Optimization | Via serverless function | Native |
| Free tier | Yes | Yes, with free credits |
| CI/CD | Yes | Yes |
| Custom domains | Yes | Yes |
| Starting price | $19/month per member | $7/month |
| Infrastructure | Netlify CDN | AWS |

For a static marketing site, Netlify is a reasonable choice. For any Next.js app using SSR, API routes, real-time features, or the App Router with streaming, the serverless model creates real limitations that a persistent server on Kuberns does not have.

Read the [Netlify alternatives guide](https://kuberns.com/blogs/best-netlify-alternatives/) for a detailed comparison across more platforms.

<a href="https://dashboard.kuberns.com" target="_blank" rel="noopener noreferrer">
  <img src="https://kuberns-blogs.s3.ap-south-1.amazonaws.com/deploy-on-kuberns-bannner9.png" alt="Start deploying on Kuberns" style={{ width: "100%", height: "auto" }} />
</a>

## Frequently Asked Questions

**Do I need to install the Netlify CLI to deploy Next.js?**

No. Netlify CLI is optional. The dashboard-based deployment through GitHub is the standard path and does not require any CLI tools.

**Why does my Next.js API route work locally but fail on Netlify?**

The most likely cause is the function execution timeout. API routes on Netlify run as serverless functions with a maximum execution time of 10 seconds (free) or 26 seconds (paid). If your route does work that takes longer, it will time out in production even though it works fine locally with no limit.

**Can I use NextAuth.js on Netlify?**

Yes. NextAuth.js works on Netlify as long as you set `NEXTAUTH_SECRET` and `NEXTAUTH_URL` correctly in your environment variables. Make sure `NEXTAUTH_URL` is set to your production Netlify domain, not localhost.

**Does Netlify support Next.js middleware?**

Yes. Next.js Middleware runs on Netlify's Edge Functions, which are globally distributed and have very low latency. Middleware is one of the better-supported features on Netlify.

**Can I use a custom domain on Netlify for free?**

Yes. Custom domains are available on all Netlify plans including the free tier. Netlify provisions and renews SSL certificates automatically via Let's Encrypt.

**Is Kuberns better than Netlify for Next.js e-commerce?**

For e-commerce with server-rendered product pages, API routes for cart and checkout, and real-time inventory, yes. The persistent server model on Kuberns means no cold starts on SSR pages and no timeout risk on checkout API routes. These are critical for conversion rates.

---
- [More Deployment Guides articles](https://kuberns.com/blogs/category/deployment-guides/1/)
- [All articles](https://kuberns.com/blogs/)