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

uniqueginun's avatar

Inertia switch rootView conditionally

Hello everyone

I'm using inertia with Vue in Laravel 8 app. and I have two blade layout files. guest.blade.php for auth components and app.blade.php for anything else.

As mentioned in the docs, I can set rootView blade layout file to be rendered as bellow.

public function rootView(Request $request): string
    {
        if ($request->route()->getPrefix() !== '/auth') {
            return 'app';
        }

        return 'guest';
    }

when I go to /auth/login it renders guest.blade.php. but after login and redirect to /dashboard it keeps the old layout file instead of app.blade.php and only render it when I refresh the page.

any solution to this problem.

0 likes
1 reply
bugsysha's avatar

No built-in feature for this. Not sure why would you use different template files. I would rewrite that so it uses the same root view.

Please or to participate in this conversation.