next.js
next.js copied to clipboard
Docs: How to migrate from async router.push to new `next/navigation` push method
What is the improvement or update you wish to see?
The new router in next/navigation
no longer returns a promise from the push
method. From what I've been able to understand, this is so that it can work with the startTransition
feature of React, but the Next docs don't contain any information about this or how to successfully replace any functionality that was relying on "awaiting" a router.push call
Is there any context that might help us understand?
The docs for the push method are currently one sentence here: https://nextjs.org/docs/app/api-reference/functions/use-router#userouter
The migration guide does not mention the fact that the method is no longer async or describe how a migration should take place to the new push
https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-5-migrating-routing-hooks
This is the one place I've been able to find mention of how it can be used with useTransition, although it also doesn't seem to trigger the pending state in many cases (maybe it just doesn't work in page router?) https://github.com/vercel/next.js/discussions/49810
Does the docs page already exist? Please link to it.
https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#step-5-migrating-routing-hooks