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
> Visits made to the same URL automatically set `replace` to `true`.
402
402
403
+
# Client side visits
404
+
405
+
You can use the `router.push` and `router.replace` method to make client-side visits. This method is useful when you want to update the browser's history without making a server request.
406
+
407
+
:::tabs key:frameworks
408
+
== Vue
409
+
410
+
```js
411
+
import { router } from'@inertiajs/vue3'
412
+
413
+
router.push({
414
+
url:'/users',
415
+
component:'Users',
416
+
props: { search:'John' },
417
+
clearHistory:false,
418
+
encryptHistory:false,
419
+
preserveScroll:false,
420
+
preserveState:false,
421
+
})
422
+
```
423
+
424
+
== React
425
+
426
+
```js
427
+
import { router } from'@inertiajs/react'
428
+
429
+
router.push({
430
+
url:'/users',
431
+
component:'Users',
432
+
props: { search:'John' },
433
+
clearHistory:false,
434
+
encryptHistory:false,
435
+
preserveScroll:false,
436
+
preserveState:false,
437
+
})
438
+
```
439
+
440
+
== Svelte 4|Svelte 5
441
+
442
+
```js
443
+
import { router } from'@inertiajs/svelte'
444
+
445
+
router.push({
446
+
url:'/users',
447
+
component:'Users',
448
+
props: { search:'John' },
449
+
clearHistory:false,
450
+
encryptHistory:false,
451
+
preserveScroll:false,
452
+
preserveState:false,
453
+
})
454
+
```
455
+
456
+
:::
457
+
458
+
All the parameters are optional. By default, all passed parameters will be merged with the current page. This means you are responsible for overriding the current page's URL, component, and props.
459
+
460
+
If you need access to the current page's props you can pass a function to the props option. This function will receive the current page's props as an argument and should return the new props.
> Make sure that any route you push on the client side is also defined on the server side. If the user refreshes the page, the server will need to know how to render the page.
500
+
403
501
## State preservation
404
502
405
503
By default, page visits to the same page create a fresh page component instance. This causes any local state, such as form inputs, scroll positions, and focus states to be lost.
0 commit comments