I have used this instruction from inertiajs official website to share user auth data and it works fine for all pages except those who doesn't directly rendered by Inertia::render() method.
I need to access user authentication data from a layout component named <Master> but I can't!
here is my structure/heirarchy:
- Vue/
- Pages/
- Home/
- Index.vue
- Layouts/
- Master.vue
- Header.vue
- Footer.vue
- App.js
here is my <Master> component:
<template>
<Head>
<title>My Title</title>
</Head>
<Header :user="user"/>
<slot/>
<Footer/>
</template>
<script>
import Header from './Header';
import Footer from './Footer';
import {Head} from '@inertiajs/inertia-vue3';
export default {
data() {
return {
user: this.auth.user,
}
},
props:{
auth: Object,
},
components: {
Header,
Footer,
Head,
}
}
</script>