@@ -34,8 +34,8 @@ package = "@netlify/plugin-nextjs"
34
34
## Deploying
35
35
36
36
If you build on Netlify, this plugin will work with no additional configuration. However if you are building and
37
- deploying locally using the Netlify CLI, you must deploy using ` netlify deploy --build ` . Running the
38
- build and deploy commands separately will not work, because the plugin will not generate the required configuration.
37
+ deploying locally using the Netlify CLI, you must deploy using ` netlify deploy --build ` . Running the build and deploy
38
+ commands separately will not work, because the plugin will not generate the required configuration.
39
39
40
40
## Migrating from an older version of the plugin
41
41
@@ -67,9 +67,26 @@ If you currently use redirects or rewrites on your site, see
67
67
for information on changes to how they are handled in this version. In particular, note that ` _redirects ` and ` _headers `
68
68
files must be placed in ` public ` , not in the root of the site.
69
69
70
- If you want to use Next 12's beta Middleware feature, this will mostly work as expected but please
71
- [ read the docs on some caveats and workarounds] ( https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md )
72
- that are currently needed.
70
+ ## Next.js Middleware on Netlify
71
+
72
+ Next.js Middleware works out of the box on Netlify, but check out the
73
+ [ docs on some caveats] ( https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md ) . By default,
74
+ middleware runs using SSR. For better results, you should enable [ Netlify Edge Functions] ( #netlify-edge-functions ) ,
75
+ which ensures middleware runs at the edge.
76
+
77
+ ### No nested middleware in Next 12.2.0
78
+
79
+ In Next 12.2.0, nested middleware [ has been deprecated] ( https://nextjs.org/docs/messages/middleware-upgrade-guide ) in
80
+ favor of root level middleware. If you are not using edge functions then this means that you won't get the benefits of
81
+ using a CDN, and ISR will not work.
82
+
83
+ To fix this issue, you can run your middleware on [ Netlify Edge Functions] ( #netlify-edge-functions ) .
84
+
85
+ ## Netlify Edge Functions
86
+
87
+ To use Netlify Edge Functions for middleware or to enable
88
+ [ edge server rendering] ( https://nextjs.org/blog/next-12-2#edge-server-rendering-experimental ) , set the environment
89
+ variable ` NEXT_USE_NETLIFY_EDGE ` to ` true ` .
73
90
74
91
## Monorepos
75
92
0 commit comments