Inertia

The Inertia standard — conventions for writing and reviewing Inertia.js code, the bridge between Laravel backends and frontend apps.

elliottlawson 07b838c 1.2 KB Updated

File contents

Inertia

Apply these conventions alongside the laravel conventions.

Server side

  • Controllers return Inertia::render(), not views or raw JSON for page responses.
  • Props are lazy. Wrap expensive values in closures so they resolve only when the page actually needs them — otherwise every partial reload pays for every query.
  • Shared data lives in middleware (HandleInertiaRequests::share()), not repeated per controller.
  • Only what the page needs. Passing entire models or unbounded collections as props ships the database to the browser — shape props deliberately.

Client side

  • Forms use useForm (or <Form>) — not hand-rolled fetch/axios against the same endpoints. Validation errors come back through the form helper.
  • Page components are thin. Data arrives as props; a page component that fetches its own data on mount is working against the pattern.
  • Partial reloads (router.reload({ only: [...] })) instead of full visits when only part of the page's data changed.

elliottlawson/open-review/tree/main/skills/conventions/inertia commit 07b838cdf0

Frequently asked questions

npx skillmds@latest add elliottlawson/inertia