@@ -102,27 +102,15 @@ function Component() {
102
102
This concept of _ "shallow routing"_ is done via updates to the browser's
103
103
[ History API] ( https://developer.mozilla.org/en-US/docs/Web/API/History_API/Working_with_the_History_API ) .
104
104
105
- While the ` useOptimisticSearchParams ` and the adapter itself can handle shallow URL
106
- updates triggered from state updater functions, for them to react to URL changes
107
- triggered by explicit calls to the History API (either by first or third party code),
108
- you'd have to enable sync:
109
-
110
- ``` tsx
111
- // Export available in:
112
- // 'nuqs/adapters/remix'
113
- // 'nuqs/adapters/react-router/v6'
114
- // 'nuqs/adapters/react-router/v7'
115
- // 'nuqs/adapters/react'
116
- import { enableHistorySync } from ' nuqs/adapters/remix'
117
-
118
- // Somewhere top-level (like app/root.tsx)
119
- enableHistorySync ()
120
- ```
121
-
122
- Note that you may not need this if only using your framework's router.
123
-
124
- It is opt-in as it patches the History APIs, which can have side effects
125
- if third party code does it too.
105
+ <Callout title = " Why not using shouldRevalidate?" >
106
+ [ ` shouldRevalidate ` ] ( https://reactrouter.com/start/framework/route-module#shouldrevalidate )
107
+ is the idomatic way of opting out of running loaders on navigation, but nuqs uses
108
+ the opposite approach: opting in to running loaders only when needed.
109
+
110
+ In order to avoid specifying ` shouldRevalidate ` for every route, nuqs chose to
111
+ patch the history methods to enable shallow routing by default (on its own updates)
112
+ in React Router based frameworks.
113
+ </Callout >
126
114
127
115
## Scroll
128
116
0 commit comments