Skip to content

Commit 968c1bc

Browse files
ascorbicKyleBlankRollinskodiakhq[bot]
authored
chore: add more docs (#1130)
* chore: add more docs * chore: apply suggestions from code review Co-authored-by: Kyle Rollins <[email protected]> Co-authored-by: Kyle Rollins <[email protected]> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 3d34c37 commit 968c1bc

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ npm install -D @netlify/plugin-nextjs
3131
package = "@netlify/plugin-nextjs"
3232
```
3333

34+
## Deploying
35+
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.
39+
3440
## Migrating from an older version of the plugin
3541

3642
You can manually upgrade from the previous version of the plugin by running the following command:
@@ -58,7 +64,8 @@ it.
5864

5965
If you currently use redirects or rewrites on your site, see
6066
[the Rewrites and Redirects guide](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/redirects-rewrites.md)
61-
for information on changes to how they are handled in this version.
67+
for information on changes to how they are handled in this version. In particular, note that `_redirects` and `_headers`
68+
files must be placed in `public`, not in the root of the site.
6269

6370
If you want to use Next 12's beta Middleware feature, this will mostly work as expected but please
6471
[read the docs on some caveats and workarounds](https://github.com/netlify/netlify-plugin-nextjs/blob/main/docs/middleware.md)
@@ -85,6 +92,12 @@ you can remove it. Alternatively you can
8592
support. See [`demos/next-export`](https://github.com/netlify/netlify-plugin-nextjs/tree/main/demos/next-export) for an
8693
example.
8794

95+
## Asset optimization
96+
97+
Netlify [asset optimization](https://docs.netlify.com/site-deploys/post-processing/) should not be used with Next.js
98+
sites. Assets are already optimized by Next.js at build time, and doing further optimization can break your site. Ensure
99+
that it is not enabled at **Site settings > Build & deploy > Post processing > Asset optimization**.
100+
88101
## Generated functions
89102

90103
This plugin works by generating three Netlify functions that handle requests that haven't been pre-rendered. These are

docs/redirects-rewrites.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@ Netlify and Next.js redirects support different features and are evaluated at di
2424
### When to use Next.js redirects or rewrites:
2525
- If you are using a _rewrite_ that points to a dynamic Next.js page, you must use Next.js rewrites. Next.js has no way of knowing what the rewritten page is when using Netlify rewrites, so the wrong page is likely to be rendered. This only applies to redirects, not rewrites.
2626
- If you need Next.js-specific features such as regex path or header matching, you must use Next.js rewrites.
27+
28+
### Using `_rewrites` and `_headers` files
29+
30+
If you are using `_rewrites` or `_headers` files rather than a `netlify.toml` file, bear in mind that these files must be in the published directory of your site, not the root of the repo. To do this, put them in `public` and they will be moved into `.next` at build time. Do not put them directly into `.next`, because it is emptied at build time. Any `_rewrites` or `_headers` files in the root of the repo will not be found when deployed.

0 commit comments

Comments
 (0)