Blank page after router.push() in Next.js?

When working in Next.js, do you see a blank page after you programmatically call router.push()?

I had this problem too, and here’s how I solved it.

Don’t write return after calling router.push(), and don’t use it as a return value.

Never use return when you use it.

For example, don’t do this:

router.push('/')
return

And don’t do this:

return router.push('/')

Do this:

router.push('/')


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com

When working in Next.js, do you see a blank page after you programmatically call router.push()?

I had this problem too, and here’s how I solved it.

Don’t write return after calling router.push(), and don’t use it as a return value.

Never use return when you use it.

For example, don’t do this:

router.push('/')
return

And don’t do this:

return router.push('/')

Do this:

router.push('/')


This content originally appeared on flaviocopes.com and was authored by flaviocopes.com


Print Share Comment Cite Upload Translate Updates
APA

flaviocopes.com | Sciencx (2022-04-11T05:00:00+00:00) Blank page after router.push() in Next.js?. Retrieved from https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/

MLA
" » Blank page after router.push() in Next.js?." flaviocopes.com | Sciencx - Monday April 11, 2022, https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/
HARVARD
flaviocopes.com | Sciencx Monday April 11, 2022 » Blank page after router.push() in Next.js?., viewed ,<https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/>
VANCOUVER
flaviocopes.com | Sciencx - » Blank page after router.push() in Next.js?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/
CHICAGO
" » Blank page after router.push() in Next.js?." flaviocopes.com | Sciencx - Accessed . https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/
IEEE
" » Blank page after router.push() in Next.js?." flaviocopes.com | Sciencx [Online]. Available: https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/. [Accessed: ]
rf:citation
» Blank page after router.push() in Next.js? | flaviocopes.com | Sciencx | https://www.scien.cx/2022/04/11/blank-page-after-router-push-in-next-js/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.