Version 4 is a complete rewrite of the Essential Next.js plugin. For full details of everything that's new, check out the v4 release notes
The plugin should be installed automatically for new Next.js sites on Netlify. You can also install it manually like this:
- Install the module:
npm install -D @netlify/plugin-nextjs
...then add it to your netlify.toml
file:
[[plugins]]
package = "@netlify/plugin-nextjs"
You can manually upgrade from the previous version of the plugin by running the following command:
npm install -D @netlify/plugin-nextjs@latest
Change the publish
directory to .next
:
[build]
publish = ".next"
If you previously set a custom distDir
in your next.config.js
, or set node_bundler
or external_node_modules
in
your netlify.toml
these are no longer needed and can be removed.
The serverless
and experimental-serverless-trace
targets are deprecated in Next 12, and all builds with this plugin
will now use the default server
target. If you previously set the target in your next.config.js
, you should remove
it.
If you are using a monorepo you will need to change publish
to point to the full path to the built .next
directory,
which may be in a subdirectory. If you have changed your distDir
then it will need to match that.
If you are using Nx, then you will need to point publish
to the folder inside dist
, e.g. dist/apps/myapp/.next
.
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.
If you think you have found a bug in the plugin, please open an issue. If you have comments or feature requests, see the dicussion board