Respect's avatar

wired problem with blaze - component not working

  • my laravel 13 livewire 4 app component <x-sidebars.sidebar-admin /> not working in my lazyout file when use blaze ( mast put the code direct inside layout file to wroking ) if disabled blaze component works
    note: always aim clear:view and clear:cache

FULL CODE IS BELOW

AppServiceProvider.php

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Livewire\Blaze\Blaze;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void {}

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        Blaze::optimize()->in(resource_path('views/components'));
    }
}

0 likes
2 replies
imranbru's avatar
imranbru
Best Answer
Level 4

This is a classic gotcha with Blaze. Your footer-admin works fine because it's likely just static HTML, but your sidebar is tripping up the compiler.

Blaze is primarily designed as a drop-in replacement for anonymous, stateless components. Sidebars almost always break this rule in one of two ways:

Never pass your root views/components directory into Blaze. You only want to optimize "dumb", presentational UI components (buttons, badges, icons, cards, footers).

Update your AppServiceProvider to specifically target directories that don't rely on global state or backing classes:

public function boot(): void
{
    // Target specific UI folders instead of everything
    Blaze::optimize()
        ->in(resource_path('views/components/ui'))
        ->in(resource_path('views/components/icons'))
        ->in(resource_path('views/components/footers'));
}

Exclude complex structural components like navbars and sidebars from Blaze entirely and you'll be good to go.

Respect's avatar

okey thanks for clear this for me , i will use blaze partially like you said in app service provider insted of all component thanks

Please or to participate in this conversation.