You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Forms work with Inertia's useForm / <Form> without glue code: submitting, processing, progress for uploads, errors from page props and error bags, preserveScroll/preserveState, resetting. Works without Inertia too (plain fetch or native form submit).
Done on next-gen (50f7d8c). Tests are in src/inertia/inertia.test.tsx and docs in docs/advanced-usage/inertia.md.
Decisions:
Router:<FormsProvider router={inertia}> submits each form as an Inertia visit, so a plain <Form action> needs no glue. The visit sends the form's FormData with router.visit. Files and _method work as in a native submit, and PUT/PATCH/DELETE go as POST, which is what Laravel needs for multipart bodies.
Preserved state:preserveState defaults to "errors", so a failed submit keeps the user's input.
useForm(): with <Form form={useForm()}>, the form is detected by its shape (setData, submit, processing), so the core never imports Inertia. Fields read and write form.data. Bracket names map to nested data. Checkbox groups hold an array, a single checkbox holds its value or false, and radios hold the selected value. Fields that aren't in data yet are added with their starting value, so submit() sends them.
Errors and old input: they come from page props. Errors include every bag, selected with errorBag. Old input comes from an old shared prop, when the app shares one.
Links:inertiaLinks (UI adapter partial) puts Inertia's Link in the Link slot. External URLs and downloads stay plain anchors.
Without Inertia:fetchRouter handles JSON endpoints (XHR, for upload progress), or the form submits natively.
@inertiajs/react^2.0.0 || ^3.0.0 is an optional peer. Tested against 3.11.
Activity
Native Laravel Inertia support
n4ff4h commentedon Nov 4, 2026
Done on
next-gen(50f7d8c). Tests are insrc/inertia/inertia.test.tsxand docs indocs/advanced-usage/inertia.md.Decisions:
<FormsProvider router={inertia}>submits each form as an Inertia visit, so a plain<Form action>needs no glue. The visit sends the form'sFormDatawithrouter.visit. Files and_methodwork as in a native submit, and PUT/PATCH/DELETE go as POST, which is what Laravel needs for multipart bodies.preserveStatedefaults to"errors", so a failed submit keeps the user's input.useForm(): with<Form form={useForm()}>, the form is detected by its shape (setData,submit,processing), so the core never imports Inertia. Fields read and writeform.data. Bracket names map to nested data. Checkbox groups hold an array, a single checkbox holds its value orfalse, and radios hold the selected value. Fields that aren't indatayet are added with their starting value, sosubmit()sends them.errorBag. Old input comes from anoldshared prop, when the app shares one.inertiaLinks(UI adapter partial) puts Inertia'sLinkin theLinkslot. External URLs and downloads stay plain anchors.fetchRouterhandles JSON endpoints (XHR, for upload progress), or the form submits natively.@inertiajs/react^2.0.0 || ^3.0.0is an optional peer. Tested against 3.11.