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

Respect's avatar

How To Include Multiable Css js files in inertia js

Hello Friends : I need To Include Css and JS Files in Inertia js - And Inertia Support Only 1 layout.blade.php for example in laravel we use admin.layout.blade.php for admin lte dashboad bootstrap 3 and frontend.layout.blade.php for site frontend for bootstrap 4 How to include both of templates for admin and frontend in the app.

  • How To Include or handle x2 app.blade.php files on for frontend and other for backend
  • Thanks You For Trying Help
0 likes
3 replies
Respect's avatar
Respect
OP
Best Answer
Level 3

Hello Frinds | after alot of searches in the internet i found the The solution In app service provider

/* in AppServiceProvider */
public function register()
{
    // dynamically set the rootview based on whether the route is backend or frontend 
    // can also be done in a middleware that wraps all admin routes
    if(request()->is('admin/*')){
        Inertia::setRootView('admin.app');
    } else {
        Inertia::setRootView('frontend.app');
    }
    ....
}

Source Of Answer https://github.com/inertiajs/inertia-laravel/issues/22

MichalOravec's avatar

@respect I think it should be in the boot() method instead of register()

From docs: within the register method, you should only bind things into the service container.

Docs: https://laravel.com/docs/7.x/providers#the-register-method and https://laravel.com/docs/7.x/providers#the-boot-method

Also if you use route which starts with admin. you can use Route::is('admin.')

/**
 * Bootstrap services.
 *
 * @return void
 */
public function boot()
{
    if (request()->is('admin/*')) {
        Inertia::setRootView('admin.app');
    } else {
        Inertia::setRootView('frontend.app');
    }

    // ...
}

Please or to participate in this conversation.