Skip to content

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

How to solve the blank page after you programmatically call router.push() in Next.js?

THE AHA STACK MASTERCLASS

Launching May 27th

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 20 books to help you become a better developer:

  • Astro Handbook
  • HTML Handbook
  • Next.js Pages Router Handbook
  • Alpine.js Handbook
  • HTMX Handbook
  • TypeScript Handbook
  • React Handbook
  • SQL Handbook
  • Git Cheat Sheet
  • Laravel Handbook
  • Express Handbook
  • Swift Handbook
  • Go Handbook
  • PHP Handbook
  • Python Handbook
  • Linux Commands Handbook
  • C Handbook
  • JavaScript Handbook
  • CSS Handbook
  • Node.js Handbook
...download them all now!

Related posts that talk about next: