From 2517a8ede1fa22e9cccad7a81fe03367a36e2e1c Mon Sep 17 00:00:00 2001 From: Pol Marnette Date: Sun, 1 Nov 2020 17:25:47 +0100 Subject: [PATCH] Doc about redirect on getServerSideProps --- docs/basic-features/data-fetching.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/basic-features/data-fetching.md b/docs/basic-features/data-fetching.md index 7f973189425d8..c1d9cdb6bbf97 100644 --- a/docs/basic-features/data-fetching.md +++ b/docs/basic-features/data-fetching.md @@ -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. } } ``` @@ -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. >