Skip to content

Commit 7fbefc2

Browse files
serpentbladeclaude
andcommitted
docs(inertia): add the Inertia page + Filament callout on Livewire
Inertia is API-shaped on the server — query → hydrate → serialize props → JSON, the path the benchmarks already measure — so it needs no dedicated axis, just a page that says so. Frame it as the easy case opposite Livewire: plain JSON props, no HMAC snapshot, so no byte-identity subtlety beyond Grease's standing promise. Add it to the Introduction nav next to Octane/Livewire. Also add a one-liner on the Livewire page: Filament is Livewire-based and a Filament table is the canonical query-active update (re-queries on every sort/filter/page), so it benefits on every interaction. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a6c144b commit 7fbefc2

3 files changed

Lines changed: 56 additions & 0 deletions

File tree

docs/.vitepress/config.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default defineConfig({
6969
{ text: 'Why Grease', link: '/guide/why' },
7070
{ text: 'Grease & Octane', link: '/guide/octane' },
7171
{ text: 'Grease & Livewire', link: '/guide/livewire' },
72+
{ text: 'Grease & Inertia', link: '/guide/inertia' },
7273
{ text: 'Getting Started', link: '/guide/getting-started' },
7374
],
7475
},

docs/guide/inertia.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Grease & Inertia
2+
3+
## On the server, an Inertia visit *is* an API request — Grease greases it the same way
4+
5+
[Inertia](https://inertiajs.com) moves rendering to Vue/React on the client, but the server
6+
half never changes shape. A controller queries its models, serializes them into props, and
7+
returns JSON:
8+
9+
```php
10+
return Inertia::render('Users/Index', [
11+
'users' => User::with('posts')->get(),
12+
]);
13+
```
14+
15+
On the PHP side that's query → hydrate → serialize → respond — the exact path the
16+
[benchmarks](/guide/benchmarks) and `realworld.php` already measure on a plain JSON endpoint.
17+
Every visit is a fresh request; there's no persistent server-side component state. So the tiers
18+
land precisely as they do on an API route:
19+
20+
- **Model hydration / casting** — the controller queries the models behind the props.
21+
- **`toArray()` + date serialization** — Inertia serializes props to JSON through the same path,
22+
so a model or resource prop runs the [date/cast tiers](/guide/serialization-helpers).
23+
- **Container / request / router / events** — the request envelope, greased like any route.
24+
25+
There's nothing Inertia-specific to install or configure: the model + serialization tiers are
26+
your props, the foundation tiers are the request. Add `HasGrease` to the models your controllers
27+
return and the existing [API numbers](/guide/benchmarks) are your numbers.
28+
29+
## The easy case — no snapshot, no checksum
30+
31+
Where [Livewire](/guide/livewire) ships a checksummed snapshot of model state between requests —
32+
a real place a one-byte serialization drift could break rehydration — Inertia carries no such
33+
thing. Props are plain JSON in the response, regenerated from scratch every visit; nothing is
34+
HMAC-sealed, no state round-trips through the browser. So there's no byte-identity subtlety to
35+
reason about beyond Grease's standing promise that serialized output is
36+
[byte-identical to vanilla](/guide/why#the-one-rule-byte-identical-output) — which every tier
37+
already keeps. Partial reloads (`only`/`except`) just send a subset of those same props: still a
38+
fresh request, fewer props serialized.
39+
40+
(Inertia's SSR renders Vue/React in a Node process — Grease is a PHP package and doesn't touch
41+
it. The PHP side still only produces the props JSON, and that's what gets greased.)
42+
43+
## Getting started
44+
45+
Add `HasGrease` to the [Eloquent models](/guide/getting-started) your controllers pass as props —
46+
that's the whole story. The [Blade component tier](/guide/blade) barely applies (Inertia's only
47+
Blade is the root `app.blade.php` rendered once on the first load; every visit after is JSON), but
48+
the [container](/guide/container), [request](/guide/request), [router](/guide/routing), and
49+
[event](/guide/events) tiers all apply to the request like any other route and compound on top. An
50+
Inertia app is an API app wearing a SPA — greasing it is the same work, in the same place.

docs/guide/livewire.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ cheap with or without Grease, and that's fine. The win tracks the work: an inter
8383
model work gets greased every time; one that does none costs nothing either way. So the more your
8484
components actually *do* per click, the more this is doing for you.
8585

86+
This is why **[Filament](https://filamentphp.com)** benefits so directly: it's built on Livewire,
87+
and a Filament table re-queries on every sort, filter, and page — the query-active shape, on every
88+
interaction. Put `HasGrease` on the models behind your resources and every table interaction takes
89+
the greased path.
90+
8691
## Getting started
8792

8893
There's nothing Livewire-specific to install or configure. Add `HasGrease` to the

0 commit comments

Comments
 (0)