You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, `/about` would resolve to the state `{page: 'about'}` which unambiguously can map back to `/page`, and an empty state can map to `/`. To figure out if you are on the index page, you can check for `state.page == null`, (and set the state.page to null to navigate back to the index)
137
141
138
-
139
142
## Search params
140
143
141
144
URL search parameters will be decoded and made available on the special `_searchParams` key of the router state. This is which is an array of `[key: string, value: string]` tuples, similar to what you'd get from `URLSearchParams.entries()`.
@@ -153,7 +156,9 @@ const router = useRouter()
153
156
154
157
console.log(router.state)
155
158
```
159
+
156
160
Will log
161
+
157
162
```ts
158
163
{
159
164
someParam: 'something',
@@ -168,15 +173,19 @@ const router = useRouter()
168
173
169
174
router.navigate({
170
175
someParam: 'something',
171
-
_searchParams: [['foo', 'bar'], ['bar', 'baz']]
176
+
_searchParams: [
177
+
['foo', 'bar'],
178
+
['bar', 'baz'],
179
+
],
172
180
})
173
181
```
182
+
174
183
Will navigate to:
184
+
175
185
```
176
186
/path/to/something?foo=bar&bar=baz
177
187
```
178
188
179
-
180
189
### Transforming path parameters
181
190
182
191
Query parameters doesn't work too well with router scopes as they operate in a global namespace. A possible workaround is to "fake" query params in a path segment using transforms:
0 commit comments