← flaviocopes.com

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

Published Apr 11 2022

Psssst! The 2023 WEB DEVELOPMENT BOOTCAMP is starting on FEBRUARY 01, 2023! SIGNUPS ARE NOW OPEN to this 10-weeks cohort course. Learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much more! ✨

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('/')


I write books for developers 👇🏼

© 2023 Flavio Copes Flavio Copes made in Italy 🇮🇹 using Notion to Site Notion to Site