Skip to content

HandleRequests

Magewire specific (since: 3.0.0)

HandleRequests (sort order 1200) is the entry point for subsequent requests — the /magewire/update XHR that fires when a user interacts with a component. It receives the POST, drives HandleComponents for each component in the payload, and assembles the JSON response.

On an initial page render this mechanism does nothing; the work happens only on update roundtrips.

The update flow

A Magewire update is a single POST carrying one or more component payloads. handleUpdate() walks them:

  1. Read the components array from the request.
  2. Fire the request event (lets features inspect/transform the raw payload).
  3. For each component payload:
  4. magewire:component:reconstruct — rebuild the block and component from the snapshot (via its resolver).
  5. Mark the component as updating: store($component)->set('magewire:update', $payload).
  6. Render the block ($block->toHtml()), which runs the component lifecycle through HandleComponents.
  7. Collect the new snapshot and effects.
  8. Fire the response event and return the assembled payload:
{
  "components": [
    { "snapshot": "…serialized snapshot…", "effects": { "…": "…" } }
  ],
  "assets": []
}

The browser runtime takes each component's new snapshot and effects, morphs the DOM, and applies the effects (redirects, dispatched events, flash messages, …).

Identifying a Magewire request

$handleRequests->isMagewireRequest(); // true on a /magewire/update XHR

Internally this just asks the runtime whether the mode is SUBSEQUENT — the single source of truth for "are we on an update request?".

Routing is Magento's, not Livewire's

The ported Livewire class still carries Laravel route helpers (findUpdateRoute(), route macros). In Magewire those are Portman leftovers — the actual endpoint is wired through a Magento controller (MagewireUpdateRoute), which boots the runtime in SUBSEQUENT mode and hands off to this mechanism. The update URI is exposed to templates via utils()->magewire()->getUpdateUri() (see View Model & Utilities).

  • Mechanisms — the pipeline overview.
  • HandleComponents — the lifecycle this mechanism invokes per component.
  • RuntimeSUBSEQUENT mode and the boot trigger.
  • Resolvers — how each component is reconstructed from its snapshot.