You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: errors/gssp-export.md
+26-2Lines changed: 26 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,37 @@
2
2
3
3
#### Why This Error Occurred
4
4
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).
6
8
7
9
#### Possible Ways to Fix It
8
10
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**!
0 commit comments