Docs: Missing information about redirecting
See original GitHub issueFeature request
Is your feature request related to a problem? Please describe.
I’ve been looking through the docs and I can’t seem to find any information on how to redirect. There used to be a wiki page but that got deleted, and so the only information I could find are in GitHub issues.
- So it seems okay to redirect in
getInitialProps, however that is being deprecated in favor ofgetServerSideProps. Is it safe to redirect in there? - However, @Timer said that you shouldn’t redirect in
getInitialPropsusing the client-side router (here). Which makes the method that was mentioned in the original wiki page incorrect.
So what is the best way to redirect in the current version of next? Looking at zeit.co it looks like its being done in getInitialProps but I can’t be sure. If I had to venture a guess you should do it in getServerSideProps and useEffect in the function for client-side redirection.
Describe the solution you’d like
A page that describes the recommended way to redirect on the server-side and/or client side.
Describe alternatives you’ve considered
N/A
Additional context
N/A
Issue Analytics
- State:
- Created 3 years ago
- Reactions:19
- Comments:13 (7 by maintainers)
Top Results From Across the Web
My Documents folder missing - using Folder Redirection
Actually, when the folder is redirected, it means that the folder is stored in another place. But as we can see that when...
Read more >Interesting "Bug" in GroupPolicy Folder Redirection results in ...
You apply a policy that re-directs the Documents folder to say \\server1\username. This policy has the flag 'Move contents to new location' ...
Read more >Why is my page missing from Google Search?
If the tool says that the page has not been indexed. Read the documentation to learn why, and how to fix it. Here...
Read more >RFC: Returning redirects from getServerSideProps ... - GitHub
Docs: Missing information about redirecting #11797. RFC. After getServerSideProps and getStaticProps were introduced there was a lot of ...
Read more >Accessing links for missing documents does not redirect to ...
Information · 1.Set up the custom error pages for 404 status. · 2. Upload a document to any one of the libraries. ·...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Opened a RFC for redirecting here: #14890
There’s docs for this at the end of this section: https://nextjs.org/docs/basic-features/data-fetching#getstaticprops-static-generation
Can we close?