Next.js on Netlify (original) (raw)

Netlify supports all major Next.js features with zero configuration, via our open-source OpenNext adapter. This adapter is thoroughly tested with every Next.js release.

For Next.js versions prior to 13.5, visit the legacy runtime page.

If you have an existing Next.js app you’d like to deploy, push your code to a Git provider and connect it through the Netlify Dashboard.

When starting from scratch, the fastest way is to deploy our Next.js platform starter template to your Netlify account.

Deploy to Netlify

Next.js support on Netlify

Section titled “Next.js support on Netlify”

The following tables show you a comprehensive mapping of critical Next.js features and how Netlify supports them. Netlify supports new Next.js features as early as possible, but experimental features may not be fully stable yet.

Next.js Feature Support Notes
App Router Full Support
Server-Side Rendering (SSR) Full Support
Incremental Static Regeneration (ISR) Full Support
Static Site Generation (SSG) Full Support.Pre-rendered pages are stored in Next.js route cache, and fetched from the route cache by a function invocation when first accessed after a deploy.
React Server Components Full Support
Server Actions Full Support
Response Streaming Full Support
asynchronous work with next/after Full Support.Learn more in the API reference.
Middleware Full support.Implemented automatically via Edge Functions. Note there are some limitations, including a Node.js Middleware specific limitation.
Route Handlers Full Support
Image Optimization Full Support
Redirects and rewrites Full Support
Internationalization Full Support
Skew Protection Full Support
Draft Mode Full Support
Turbopack Full Support (dev and build)
Cache Components Full Support

How Netlify runs your Next.js app

Section titled “How Netlify runs your Next.js app”

Netlify automatically configures your project to support modern Next.js features out of the box. This is powered by our OpenNext adapter, an open source project that provisions the correct infrastructure for each part of your Next.js application without custom configuration.

We recommend that you don’t pin the adapter version. We actively maintain the adapter to support all Next.js versions starting from version 13.5 and, if you don’t pin the version, we will automatically update the adapter to the latest version on each project build for you.

What the adapter does

Section titled “What the adapter does”

When you deploy a Next.js project on Netlify, the adapter automatically:

Compatibility and testing

Section titled “Compatibility and testing”

We verify compatibility with every new stable version of Next.js. Each release of the adapter is tested using:

Each build of a Next.js site generates asset files (such as JavaScript bundles and CSS files). These files are automatically named with a unique hash derived from the build and file contents.

Additionally, the new deployment often comes with modified server-side code (e.g., React Server Components, Server Actions, Route handlers, etc.).

If a new production deployment goes live while visitors are in the middle of a session, it can cause several subtle issues:

These issues are difficult to consistently reason about and prevent without coordinated support from both the web framework and the deployment platform.

How skew protection works

Section titled “How skew protection works”

Skew protection addresses these challenges by synchronizing client requests with the correct deployment:

Enabling skew protection

Section titled “Enabling skew protection”

Skew protection is an opt-in feature. To enable it:

  1. Add an environment variable to your project configuration. Set the variable name to NETLIFY_NEXT_SKEW_PROTECTION and its value to true.
  2. If you’re using a Next.js version earlier than 14.1.4, you also need to include the following flags in your next.config.js file:

/** @type {import('next').NextConfig} */

const nextConfig = {

  experimental: {

    useDeploymentId: true,

    // Optionally, use with Server Actions

    useDeploymentIdServerActions: true,

  },

};

  1. Redeploy your project for the changes to take effect.

Limitations of skew protection

Section titled “Limitations of skew protection”

To adjust this behavior, you have two options:

  1. Next.js 15.4.0 introduced a new experimental feature to handle these cases. Netlify supports this feature. However, that feature is not yet production-ready.
  2. Alternatively, you can direct specific fetch calls to the correct deployment by adding a header:

fetch('/path', {

  headers: {

    'x-deployment-id': process.env.NEXT_DEPLOYMENT_ID

  },

});

Netlify detects this header and will rewrite the request to the correct deployment.

Reverting to an older adapter version

Section titled “Reverting to an older adapter version”

To pin a specific version of the adapter:

  1. Install the version you want in package.json:
npm install @netlify/plugin-nextjs@<version>  
  1. Add the plugin to your netlify.toml:
[[plugins]]  
package = "@netlify/plugin-nextjs"  

You’ll be opting out of automatic updates and newer architecture improvements maintained through OpenNext. To opt back in, remove @netlify/plugin-nextjs from your package.json.

Open issues are documented in the end-to-end test report page.