Add shallow routing option with next/navigation's router #48320
Replies: 4 comments 7 replies
-
+1 another work around right now we are leveraging is to only use Layout and having the |
Beta Was this translation helpful? Give feedback.
-
In the meantime, I've been using
in a |
Beta Was this translation helpful? Give feedback.
-
To achieve this and basically watch the URL changes on components I used the code below:
|
Beta Was this translation helpful? Give feedback.
-
Up to now, it seems shallow routing option has not been supported in next/navigation's router yet. I have a project named LafTools(laf-tools.com) using next.js, to avoid reloading page, I'm currently using other workaround as below
function push(url: string){ Just FYI, hopefully it makes senses. |
Beta Was this translation helpful? Give feedback.
-
Goals
Provide an option in next/navigation's router's
push
method to allow for shallow routing, similar to Next 12's shallow routing.Background
Currently, the recommended approach to mutate search params is to use
router.push
to update the url. However, this causes the page to reload and all the components to remount. This can have undesirable affects, such as triggering animations or other effects that trigger on mount. If the search params are being updated frequently, say with each keystroke, this can cause a very jarring experience. A{ shallow: true }
option like in Next 12's router would allow the consumer to mutate the url without remounting the components.Beta Was this translation helpful? Give feedback.
All reactions