Inertiajs - Switch to another page locally

Viewed 38

I would like to know how to switch between different pages on the client side only, without inertia.visit().

I am using Laravel and Inertiajs.

I understand that props must be specified from the laravel side in order to move to another page.

Is there any way to switch pages without communication between client and server?

I want to switch pages only on the client side with the URL, not by switching components within the same page.

1 Answers

Not sure if you are asking for this, but InertiaJS has an alternative for manual visits - the InertiaJS Link:

<template>
  <Link href="/myPage" v-text="`Click me`" />
</template>

<script setup>
  import { Link } from '@inertiajs/inertia-vue3'
</script>

Logically, anyways you'll have to register a route in routes/web.php, else you'll get a 404:

Route::get('/myPage', function () {
  return inertia('MyPage');
});
Related