---
title: "Inertia v3 with Vue"
description: "Inertia v3 patterns in the Vue kit: how pages receive data, the Form component, useForm, visits, shared props, flash toasts and typed Wayfinder routes."
---
# Inertia
The kit runs on Inertia v3 (`@inertiajs/vue3` ^3, `inertiajs/inertia-laravel` ^3). We don't use Axios or a separate API. Every request is either an Inertia visit, a `
```
These are the `
```
:::
::: details View create/edit modal (UserFormModal)
```vue
```
:::
### `useForm`
Reach for `useForm` when a form isn't made of native inputs. The card pickers on Settings → Layout and Setup → Layout are an example.
```ts
const form = useForm({ app_layout: props.layoutSettings?.app_layout || 'sidebar' });
form.patch('/settings/layout', {
preserveScroll: true,
onSuccess: () => form.defaults(),
});
```
## Visits, links and requests
| Need | Use | Example in the kit |
| --- | --- | --- |
| Navigate with a link | `Link` (or `TextLink`) with a Wayfinder object as `href` | `` |
| Search, filter, delete, one-off action | `router.get/post/patch/put/delete` with `.url()` | User search, user delete |
| Refresh or clear data | `router.reload()`, `router.visit()`, `router.flushAll()` | `flushAll()` on logout in `UserMenuContent.vue` |
| JSON without a page visit | `useHttp().submit(route())` | QR code and recovery codes in `useTwoFactorAuth.ts` |
```ts
router.get(index.url(), { search: value.trim() || undefined }, { preserveScroll: true, replace: true });
router.delete(destroy.url(user.id), { preserveScroll: true });
```
::: details View useHttp example
```ts
import { useHttp } from '@inertiajs/vue3';
import { qrCode } from '@/routes/two-factor';
const http = useHttp();
const { svg } = (await http.submit(qrCode())) as { svg: string; url: string };
```
:::
## Shared props
Because `types/global.d.ts` registers `SharedData` with Inertia, `usePage().props` is typed in every file. The same file declares a global `PageProps` (`T & SharedData`) that you can use with `usePage()` and in layout callbacks.
You'll find every shared prop listed in [Architecture → Shared props](/docs/vue/architecture#shared-props).
::: details View the type registration
```ts
declare module '@inertiajs/core' {
export interface InertiaConfig {
sharedPageProps: SharedData;
}
}
```
:::
## Flash toasts
```text
Inertia::flash('toast', [...]) → router 'flash' event
→ lib/flashToast.ts → vue-sonner toast[type](message)
```
A controller flashes the toast just before it redirects:
```php
Inertia::flash('toast', ['type' => 'success', 'message' => __('modules/tenant.toasts.created')]);
```
`type` can be `success`, `info`, `warning` or `error` (see `FlashToast` in `types/ui.ts`). The listener is `initializeFlashToast()`, which `app.ts` starts. If you need a toast from the client side, use `import { toast } from 'vue-sonner'`.
::: warning
Only the app layouts mount the `Toaster`, so toasts won't appear on auth pages.
:::
::: details View lib/flashToast.ts
```ts
export function initializeFlashToast(): void {
router.on('flash', (event) => {
const flash = (event as CustomEvent).detail?.flash;
const data = flash?.toast as FlashToast | undefined;
if (!data) {
return;
}
toast[data.type](data.message);
});
}
```
:::
## Wayfinder routes
Wayfinder turns your named routes and controller methods into typed functions. We run the Vite plugin with `formVariants: true`, which gives every function a `.form()` as well.
| Call | Returns | Use with |
| --- | --- | --- |
| `index()` | `{ url, method }` | `Link :href`, `