afraz's avatar
Level 3

How to switch Inertia.js Root View in laravel without refreshing the page.

I have a website where I want to setup multiple layouts.

auth layout : for (login, register etc) pages

dashboard layout: for authenticated users to show dashboard and all other pages related to it there.

I have tried to change root view in controller but it didn't work

Inertia::setRootView('dashboard');

dashboard.blade.php : it contains sidebar for logged in users and have different style theme

<!doctype html>
...
<div class="rt-wrapper">
     @include('partials.sidebar')
     <main id="rt-main" class="rt-main rt-haslayout">
        <div class="rt-dashboard">
             @inertia
        </div>
     </main>
</div>
...
</html>

auth.blade.php : it only contains login, register etc pages and no sidebar with different style theme.

<!doctype html>
...
<div class="rt-wrapper rt-wrappernopadding">
    <div class="rt-loginpagewrapper">
        @inertia
    </div>
</div>
...
</html>
0 likes
3 replies
afraz's avatar
Level 3

I am using layouts. But I dont want to load all libraries on all pages. Auth pages are very basic with styling only and dashboard pages have some libraries and different styling.

That's why I wanted to do that.

Please or to participate in this conversation.