Skip to content

@netlify/plugin-nextjs v4.0.0

Compare
Choose a tag to compare
@token-generator-app token-generator-app released this 14 Dec 11:03
41f5719

This is a full rewrite of the Essential Next.js plugin, with a new architecture that gives greater compatibility and stability.

What's new

  • Full support for incremental static regeneration (ISR).
  • Full support for Next.js rewrites, redirects and headers.
  • Beta support for Next 12 Middleware
  • Faster builds and deploys. Instead of generating one function per route, there are just three functions per site and a much smaller list of rewrites.
  • Full support for Netlify's new persistent On-Demand Builders. Return fallback: "blocking" from getStaticPaths and your rendering will be deferred until the first page load, then persisted globally.
  • A new image server for next/image, built on Nuxt's ipx. This is a high-performance, framework-agnostic image server based on sharp. This implementation uses On-Demand Builders to persist transformed images globally. Improved source image caching reduces time-to-first-byte for new transforms.
  • Simplified configuration. You no longer need to set any Netlify-specific configuration options. For example, in a monorepo all you need to do is set publish to point to your .next directory and you can build the site in any way you like.
  • Removes requirement for the target to be set to serverless, which is deprecated in Next 12.
  • Bundling now uses Next.js's own node-file-trace, giving more predictable results and smaller uploads.

Breaking changes

The publish directory should point to the site's .next directory or distDir if set, rather than out as in previous versions of the plugin.

Migration guide

Change the publish directory to .next:

[build]
publish = ".next"

If you previously set these values, they're no longer needed and can be removed:

  • target: "serverless" in your next.config.js
  • distDir in your next.config.js
  • node_bundler = "esbuild" in netlify.toml
  • external_node_modules in netlify.toml

If you currently use redirects or rewrites on your site, see the Rewrites and Redirects guide for information on changes to how they are handled in this version.

If you want to use Next 12's beta Middleware feature, this will mostly work as expected but please read the docs on some caveats and workarounds that are currently needed.