Skip to content

Native Laravel Inertia support #7

Closed

Description

@n4ff4h

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).

Activity

  1. added
    next-genNext-gen Javaabu packages
    featurePackage feature from the spec
    on Nov 4, 2026
  2. added a commit that references this issue on Nov 4, 2026
    50f7d8c
  3. n4ff4h commented on Nov 4, 2026

    @n4ff4h
    CollaboratorAuthor

    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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurePackage feature from the specnext-genNext-gen Javaabu packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions