Files
Jam Balaya 6f4352993d docs: add and unify notes to error pages (#72838)
## Description
Unify the note format according to the [contribution
guide](https://nextjs.org/docs/community/contribution-guide#notes).
In addition, add missing bullet points to useful links.

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening
the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution
follows the docs guidelines:
https://nextjs.org/docs/community/contribution-guide

---------

Co-authored-by: Delba de Oliveira <32464864+delbaoliveira@users.noreply.github.com>
2024-11-19 09:44:42 +00:00

53 lines
1.7 KiB
Plaintext

---
title: '`getServerSideProps` Export Error'
---
## Why This Error Occurred
You attempted to statically export your application via `output: 'export'` or `next export`, however, one or more of your pages uses `getServerSideProps`.
It is not possible to use `getServerSideProps` without a server, so you'll need to use `next start` when self hosting or deploy to a provider like [Vercel](https://vercel.com).
## Possible Ways to Fix It
1. If you'd like to keep your application static, you can use `getStaticProps` instead of `getServerSideProps`.
2. If you want to use server-side rendering, update your build command and remove `output: 'export'` and remove `next export`. For example, in your `package.json`:
```diff
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"scripts": {
"dev": "next dev",
- "build": "next build && next export",
+ "build": "next build",
"start": "next start"
}
}
```
```diff
--- a/next.config.js
+++ b/next.config.js
@@ -1,4 +1,4 @@
{
module.exports = {
reactStrictMode: true,
- output: "export",
}
}
```
> **Note**:
>
> - Removing export does not mean your entire application is no longer static.
> - Pages that use `getStaticProps` or [no lifecycle](/docs/pages/building-your-application/rendering/automatic-static-optimization) **will still be static**!
## Useful Links
- [Automatic Static Optimization](/docs/pages/building-your-application/rendering/automatic-static-optimization)
- [`getStaticProps` documentation](/docs/pages/building-your-application/data-fetching/get-static-props)
- [`exportPathMap` documentation](/docs/pages/api-reference/config/next-config-js/exportPathMap)