Blank page after router.push() in Next.js?
How to solve the blank page after you programmatically call 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('/')
→ Get my Next.js (pages router) Handbook
→ I wrote 17 books to help you become a better developer:
- C Handbook
- Command Line Handbook
- CSS Handbook
- Express Handbook
- Git Cheat Sheet
- Go Handbook
- HTML Handbook
- JS Handbook
- Laravel Handbook
- Next.js Handbook
- Node.js Handbook
- PHP Handbook
- Python Handbook
- React Handbook
- SQL Handbook
- Svelte Handbook
- Swift Handbook
Also, JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025