Skip to content

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

FULL-STACK WEB DEVELOPMENT BOOTCAMP

2024 COHORT SIGNUPS END TOMORROW

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('/')
  • Learn modern web development in my BOOTCAMP (SIGNUP END TOMORROW FEB 20, 2024)
  • THE VALLEY OF CODE (+ PRO), your web development manual
  • I wrote 15+ coding BOOKS, all available in THE VALLEY OF CODE PRO
  • Indie solopreneur internet business masterclass SOLO LAB (summer 2024)