Integrating the new Navigation API into RSC framework #11
grahammendick
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
I believe Next.js has managed to integrate this API, maybe worth digging through it's source? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've been trying to integrate the new Navigation API into my RSC framework. You can see my progress in the vid below where I first cancel a navigation by pressing 'X' and then change my mind mid-navigation. Concurrent React pairs very nicely with navigation interception. Up to a point.
Screen.Recording.2026-05-19.at.18.17.31.mov
You see, the new Navigation api is meant to work as shown below. You fetch the data in the
precommitHandlerand update the DOM in thehandler. TheprecommitHandlerruns before the URL updates and the user can cancel the navigation during this phase. Once theprecommitHandlerresolves then the browser records the scroll position and may take a screen snapshot to display during a swipe back transition (on mobile, for example).The problem is with concurrent React I can only get it working as follows. So React commits the DOM before the
precommitHandlerresolves and this messes up scroll restoration and screen snapshots, for example.Would React be interested in exposing something to RSC frameworks so they can get in between the background render completing and the changes being committed to the DOM?
Beta Was this translation helpful? Give feedback.
All reactions