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 pageshowhide
explore
- Components & Properties6 questions
- Callable Actions & Dispatch5 questions
- Data Binding & Forms5 questions
- Hydrate, Update & Render Hooks6 questions
- Lazy Loading & Navigation6 questions
- Uploaded Files in Components6 questions
- Payload Security6 questions
- Alpine Integration & JS Hooks5 questions
- Rendered State Assertions4 questions
questions
page 2 of 2In Livewire 4, how does wire:poll keep a live sales counter fresh, and what does it cost the server at scale?
basics
~10 swire: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.
What does Livewire's #[Authorize] attribute do on a component action, and how does it find the model to check?
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.
Why is a Livewire public property the wrong place for an API token or an employee's bank details, even with a checksummed snapshot?
basics
~20 sEvery 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.
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?
basics
~10 sChain 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.
In a Livewire component, how does temporaryUrl() show a preview of an uploaded file, and why can it throw for a PDF receipt?
basics
~10 stemporaryUrl() 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.
In a Livewire component, why validate the TemporaryUploadedFile yourself, and which parts of it can the user still control?
basics
~20 sLivewire'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.
In Livewire 4, when should an action use #[Renderless], skipRender() or #[Async], and what goes wrong when an #[Async] action changes component state?
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.
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?
basics
~20 sLivewire 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.
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?
basics
~20 sGive 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.
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?
basics
~20 sA 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.
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?
basics
~20 sLivewire 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.
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?
basics
~10 sAn @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.
When a Livewire component keeps an Eloquent model in a public property, what goes into the snapshot and what happens on the next request?
basics
~20 sOnly 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.
Why do Livewire update requests re-run some of the page route's middleware, and when must you call Livewire::addPersistentMiddleware()?
basics
~20 sLivewire 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.
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?
basics
~20 sLivewire::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.
In Livewire, what changes when temporary uploads go directly to S3, and what must you configure or watch for in production?
basics
~20 sSetting 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.
In Livewire, how do lifecycle hooks declared in a reusable trait get called, and why are they suffixed with the trait name?
basics
~10 sLivewire 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.
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?
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.
showing 31–49 of 49