Skip to content

Commit

Permalink
Doc about redirect on getServerSideProps
Browse files Browse the repository at this point in the history
  • Loading branch information
PolMrt authored Nov 1, 2020
1 parent 4dbf0d4 commit 2517a8e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/basic-features/data-fetching.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ If you export an `async` function called `getServerSideProps` from a page, Next.
export async function getServerSideProps(context) {
return {
props: {}, // will be passed to the page component as props
// or you can return a { redirect: {...} }, see below.
}
}
```
Expand All @@ -552,6 +553,11 @@ The `context` parameter is an object containing the following keys:
- `locales` contains all supported locales (if enabled).
- `defaultLocale` contains the configured default locale (if enabled).

You can either return `props` or a `redirect` object to redirect the user to another page. This object containing the following keys:

- `permanent`: If the redirection is permanent.
- `destination`: The destination of the redirection.

> **Note**: You can import modules in top-level scope for use in `getServerSideProps`.
> Imports used in `getServerSideProps` will not be bundled for the client-side.
>
Expand Down

0 comments on commit 2517a8e

Please sign in to comment.