skip to content

Livewire

Livewire builds reactive Laravel interfaces from server-rendered PHP components that sync state over AJAX requests. Interviewers weigh writing less JavaScript against a round trip per interaction.

on this pageshow

explore

questions

page 2 of 2

In a Livewire app, what happens when a user clicks a link marked wire:navigate, and what does @persist keep across those page visits?

level: middleimportance: should knowfreq 38%

basics

~20 s

wire:navigate intercepts the click, fetches the new page in the background and swaps in its body, title and URL without a full reload; @persist('name') keeps a matching element alive across those swaps instead of replacing it.

open as a page

In Livewire 4, how does wire:poll keep a live sales counter fresh, and what does it cost the server at scale?

level: middleimportance: should knowfreq 30%

basics

~10 s

wire:poll makes the browser send a component request on an interval, calling $refresh or a named action; in Livewire 4.4.7 the default interval is 2 seconds, so every open tab adds steady server load.

open as a page

What does Livewire's #[Authorize] attribute do on a component action, and how does it find the model to check?

level: middleimportance: should knowfreq 30%

basics

~10 s

#[Authorize('ability', 'argument')] runs a Gate check before a Livewire action executes and returns 403 on failure. The argument resolves as a class name, a type-hinted method parameter, or a component property.

open as a page

Why is a Livewire public property the wrong place for an API token or an employee's bank details, even with a checksummed snapshot?

level: middleimportance: should knowfreq 40%

basics

~20 s

Every Livewire public property is serialized into the page's wire:snapshot attribute and every update response as readable JSON. The checksum only proves the snapshot was not altered; it does not hide anything, so secrets must stay server-side.

open as a page

How do you test a Livewire sign-up component that depends on the logged-in user, a ?ref= query parameter and an uploaded CSV of contacts?

level: middleimportance: should knowfreq 30%

basics

~10 s

Chain Livewire::actingAs($member) and Livewire::withQueryParams(['ref' => 'footer']) before test(), then set('contacts', UploadedFile::fake()->create('contacts.csv', 4, 'text/csv')); Livewire simulates the whole temporary-upload flow for you.

open as a page

In a Livewire component, how does temporaryUrl() show a preview of an uploaded file, and why can it throw for a PDF receipt?

level: middleimportance: should knowfreq 30%

basics

~10 s

temporaryUrl() returns a signed URL that serves the private temporary file for previewing; it only works for extensions listed in temporary_file_upload.preview_mimes, so a PDF throws FileNotPreviewableException unless you check isPreviewable() first.

open as a page

In a Livewire component, why validate the TemporaryUploadedFile yourself, and which parts of it can the user still control?

level: middleimportance: should knowfreq 36%

basics

~20 s

Livewire's upload endpoint only enforces the global rules, so the component must validate the temporary file against the field's own rules before storing it; the original file name the user sent must still be treated as untrusted input.

open as a page

In Livewire 4, when should an action use #[Renderless], skipRender() or #[Async], and what goes wrong when an #[Async] action changes component state?

level: seniorimportance: should knowfreq 25%

basics

~20 s

#[Renderless] or skipRender() skip re-rendering after an action the view does not reflect, such as logging. Livewire 4's #[Async] runs an action in parallel instead of queued; if it mutates state, parallel requests share a snapshot and lose updates.

open as a page

In Livewire 4, when do you use interceptors such as $wire.intercept() or Livewire.interceptRequest() rather than Livewire.hook(), for example to handle 419 responses?

level: seniorimportance: should knowfreq 22%

basics

~20 s

Livewire 4 interceptors wrap network traffic at three levels, action, message and request, with onSend, onSuccess, onError and onFinish callbacks; Livewire.hook() remains for component, element and morph lifecycle events. A global request interceptor handles 419s.

open as a page

A Livewire product search binds its query and price-range inputs with wire:model.live and hammers the server while showing flickering results; how would you tune the bindings?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Give each Livewire field the timing it needs: debounce the query (wire:model.live.debounce.400ms), send price inputs on blur or Enter, keep rarely used filters deferred behind an Apply button, and show wire:dirty or loading states so users know input is pending.

open as a page

A Livewire stock-level widget keeps an Eloquent collection of products in a public property; what does that cost on every update, and how would you restructure it?

level: seniorimportance: should knowfreq 30%

basics

~20 s

A public Eloquent collection is dehydrated to class and keys, then reloaded by key on later requests without its select(), eager loads or global scopes. Keep scalar filters public, move the list to #[Computed], and persist only arrays on Laravel 13.

open as a page

In a Livewire update request, in what order do boot, hydrate, booted, the update hooks, the called action, rendering, rendered and dehydrate run, and which bugs does that order explain?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Livewire restores public state, then runs boot(), hydrate() and hydrateFoo(), booted(), the updating hooks as values are written, all updated hooks, the called actions, rendering()/rendered() around the view, and finally dehydrate() before taking the new snapshot.

open as a page

In Livewire 4, what does wrapping part of a component in @island change about re-rendering, and when would you still use a child component instead?

level: seniorimportance: should knowfreq 20%

basics

~10 s

An @island region re-renders independently: an action inside it, or one scoped with wire:island, re-renders only that region, and a normal component re-render skips it; state and hydration still belong to the whole component.

open as a page

When a Livewire component keeps an Eloquent model in a public property, what goes into the snapshot and what happens on the next request?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Only the model's class, or its morph-map alias, and primary key go into the Livewire snapshot. On each later request Livewire re-queries the row with firstOrFail, so unsaved attribute changes, loaded relations and select() constraints are gone.

open as a page

Why do Livewire update requests re-run some of the page route's middleware, and when must you call Livewire::addPersistentMiddleware()?

level: seniorimportance: should knowfreq 30%

basics

~20 s

Livewire updates hit one shared endpoint, so the page route's middleware would not run again. Livewire re-applies only middleware on its persistent list, such as auth and can; custom middleware needs Livewire::addPersistentMiddleware() in a service provider.

open as a page

A Livewire::test() suite is green but the sign-up form breaks in the browser - what can a component test not prove, and what covers the gap?

level: seniorimportance: should knowfreq 35%

basics

~20 s

Livewire::test() runs the component's PHP round trips with route middleware disabled and no browser, so it misses JavaScript, Alpine, wire:model modifiers, missing inputs, routing and middleware. An assertSeeLivewire HTTP test and a few browser tests cover those.

open as a page

In Livewire, what changes when temporary uploads go directly to S3, and what must you configure or watch for in production?

level: seniorimportance: should knowfreq 22%

basics

~20 s

Setting the temporary disk to an S3 disk makes the browser upload straight to the bucket with a presigned URL, bypassing the app server; you then need a bucket lifecycle rule for cleanup, component validation for every file, and single-file inputs.

open as a page

In Livewire, how do lifecycle hooks declared in a reusable trait get called, and why are they suffixed with the trait name?

level: middleimportance: nice to knowfreq 16%

basics

~10 s

Livewire calls trait hooks named after the hook plus the trait's class basename, such as bootHasOrderTotals() or updatedHasOrderTotals(), so several traits can each hook the same lifecycle point without colliding method names.

open as a page

In Livewire 4, how do $this->stream() and wire:stream send partial output to the browser during one action, and what are the production caveats?

level: seniorimportance: nice to knowfreq 14%

basics

~20 s

$this->stream() flushes a chunk of content to the browser while the action is still running; Livewire inserts it into the element marked wire:stream with the same name, appending by default, and renders normally when the action finishes.

open as a page

showing 31–49 of 49