[Vuejs]-Inertiajs version of axios interceptor to work on SPA first load

0👍

Figured it out. Leaving an answer in case someone else has the same issue.

Remove the router event, and the eventBus listener.

In the Styles component, mounted is triggered every time the router changes, and when it’s loaded with no router change.

Inertia has a usePage utility, which can be used in mounted.

Styles.vue

import { usePage } from '@inertiajs/vue3'

export default { 
    ...
    mounted(){
        const active_styles = usePage().props.active_styles;
        this.someFunction(active_styles);
    },
    ...
};

Leave a comment