Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

devaspid's avatar

Best Practice for Toggling Livewire Components vs Blade-Level Conditionals in Livewire 3

I'm currently using Laravel 12 with Livewire 3, and I was previously a long-time user of Livewire 2.

In Livewire 2, I commonly used Blade @if(...) to conditionally mount components based on state or user roles. However, after switching to Livewire 3, I’m adjusting to the new lifecycle behavior — especially how conditionals like @if($isFormShow) unmount the component entirely, which breaks things like event listening or dispatch.

Now I understand that in Livewire 3, we should favor wire:show to preserve component mounting and state. For example:

<div wire:show="{{ $isFormShow }}">
    <livewire:dev.form-add />
</div>

But in some cases, I still want to use conditionals that don't depend on reactive state, such as:

@if(auth()->user()->hasRole('super-user'))
    <livewire:admin.panel />
@endif


@if($user->email_verified)
    <livewire:verified-panel />
@endif

These are static conditions that won’t change during the request lifecycle, and I don’t want to trigger unnecessary re-renders or server calls just to toggle them.

I'm also considering moving these kinds of condition checks into the child component, like:

{{-- Inside <livewire:form-add /> --}}
@if(auth()->user()->hasRole('super-user'))
    <div>Only for super users</div>
@endif

This works well when I need the component to remain mounted (e.g. to receive dispatch() events).

My Questions: For static conditions like user role or email verification, is it still best practice to use Blade @if(...) in the parent view?

When is it more appropriate to move conditionals into the child component instead?

Is wire:show meant only for UI-level visibility toggling, rather than mounting logic?

Are there performance trade-offs or lifecycle issues I should be aware of between these approaches?

Thank you for the answer and help in advance.

0 likes
1 reply
Snapey's avatar

Your rendering of the page based on blade conditionals seems fine to me as you are not going to be toggling state on livewire updates for 'static' things like is the user an admin.

You should use wire:show where you need the content to remain in the dom, but hidden, eg for modals.

So, I think your understanding is correct, but perhaps you should consider altering visibility from Alpine as this will give a snappier interface. IE, you hide a modal, it hides immediately - not after a server round-trip. In a lot of cases, the livewire component does not care if a modal is open or closed, or if an input field is currently showing.

Please or to participate in this conversation.