question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs: Missing information about redirecting

See original GitHub issue

Feature 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.

  1. So it seems okay to redirect in getInitialProps, however that is being deprecated in favor of getServerSideProps. Is it safe to redirect in there?
  2. However, @Timer said that you shouldn’t redirect in getInitialProps using 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:closed
  • Created 3 years ago
  • Reactions:19
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
timneutkenscommented, Jul 6, 2020

Opened a RFC for redirecting here: #14890

1reaction
lachlanjccommented, Jan 1, 2021

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found