# Essential Next.js plugin v4 release notes

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)](https://github.com/netlify/next-runtime/blob/main/docs/isr.md).
- Full support for
  [Next.js rewrites, redirects and headers](https://github.com/netlify/next-runtime/blob/main/docs/redirects-rewrites.md).
- Beta support for [Next.js 12 Middleware](https://github.com/netlify/next-runtime/blob/main/docs/middleware.md)
- 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](https://ntl.fyi/odb). 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](https://github.com/unjs/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.js 12.
- Bundling now uses Next.js's own node-file-trace, giving more predictable results and smaller uploads.

## Migration guide

Change the `publish` directory to `.next`:

```toml
[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](https://github.com/netlify/next-runtime/blob/main/docs/redirects-rewrites.md) for
information on changes to how they are handled in this version. If you currently have `_redirects` or `_headers` files
in the root of your site, these will need to be moved into "public".

If you want to use Next.js 12's beta Middleware feature, this will mostly work as expected but please
[read the docs on some caveats and workarounds](https://github.com/netlify/next-runtime/blob/main/docs/middleware.md)
that are currently needed.
