Skip to content

Commit 63e66ef

Browse files
authored
Update gssp-export Error (vercel#15529)
This pull request updates the `gssp-export` error for clarity. Fixes vercel#15527
1 parent 5636748 commit 63e66ef

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

errors/gssp-export.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,37 @@
22

33
#### Why This Error Occurred
44

5-
You attempted to export a page with `getServerSideProps` which is not allowed. `getServerSideProps` is meant for requesting up to date information on every request which means exporting it defeats the purpose of the method.
5+
You attempted to statically export your application via `next export`, however, one or more of your pages uses `getServerSideProps`.
6+
7+
The `getServerSideProps` lifecycle is not compatible with `next export`, so you'll need to use `next start` or a [serverless deployment](https://vercel.com).
68

79
#### Possible Ways to Fix It
810

9-
If you would like the page be static you can leverage the `getStaticProps` method instead.
11+
1. If you'd like to keep your application static, you can use `getStaticProps` instead of `getServerSideProps`.
12+
13+
2. If you want to use server-side rendering, update your build command and remove `next export`. For example, in your `package.json`:
14+
15+
```diff
16+
diff --git a/bla.json b/bla.json
17+
index b84aa66c4..149e67565 100644
18+
--- a/bla.json
19+
+++ b/bla.json
20+
@@ -1,7 +1,7 @@
21+
{
22+
"scripts": {
23+
"dev": "next dev",
24+
- "build": "next build && next export",
25+
+ "build": "next build",
26+
"start": "next start"
27+
}
28+
}
29+
```
30+
31+
> **Note**: Removing `next export` does not mean your entire application is no longer static.
32+
> Pages that use `getStaticProps` or [no lifecycle](https://nextjs.org/docs/advanced-features/automatic-static-optimization) **will still be static**!
1033
1134
### Useful Links
1235

36+
- [Automatic Static Optimization](https://nextjs.org/docs/advanced-features/automatic-static-optimization)
1337
- [`getStaticProps` documentation](https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation)
1438
- [`exportPathMap` documentation](https://nextjs.org/docs/api-reference/next.config.js/exportPathMap)

0 commit comments

Comments
 (0)