# Inertia

Flux integrates with Inertia through the Inertia-specific `FluxProvider`. See [the installation guide](https://fluxui.dev/react/docs/installation) to set it up.

## Links

Every Flux component with an `href` navigates through Inertia's link component without a full page load, and accepts its props such as `prefetch`:

```tsx
<Button href="/dashboard">Dashboard</Button>

<Sidebar.Item href="/settings" prefetch>Settings</Sidebar.Item>
```

## Wayfinder routes

You can pass [Wayfinder](https://github.com/laravel/wayfinder) routes straight to `href`, including non-GET routes like `logout`, which render a button that sends the request:

```tsx
import { dashboard, logout } from '@/routes';

<Sidebar.Item href={dashboard()}>Dashboard</Sidebar.Item>

<Dropdown.Item href={logout()}>Log out</Dropdown.Item>
```

## Validation errors

Fields show their validation errors automatically, matched by `name`. Inside an Inertia `Form`, a field reads that form's errors, while elsewhere, such as with `useForm`, it reads the page's errors:

```tsx
<Form {...store.form()}>
    <Input label="Email" type="email" name="email" />

    <Input label="Password" type="password" name="password" />
</Form>
```

## Submit buttons

A submit button inside an Inertia `Form` shows a loading state and ignores clicks while the form is processing, unless you pass `loading` yourself:

```tsx
<Form {...update.form()}>
    <Input label="Name" name="name" />

    <Button type="submit" variant="primary">Save</Button>
</Form>
```

## Current page

Navbar, navlist, and sidebar items mark themselves as current when their `href` matches the page's URL, unless you pass `current`:

```tsx
<Navbar>
    <Navbar.Item href="/dashboard">Dashboard</Navbar.Item>
    <Navbar.Item href="/settings">Settings</Navbar.Item>
</Navbar>
```

## Flash toasts

Flash a toast under the `flux:toast` key from a controller to show it after the redirect, using the same options as `toast()`:

```php
Inertia::flash('flux:toast', [
    'text' => 'Profile updated.',
    'variant' => 'success',
]);

return back();
```
