[Vuejs]-Vue.js 2.0 passing Auth::user() to children components in complex hierarchy

3👍

If the Auth::user() is stored on the root instance as authUser the simplest way to access it in your child components would be to use this.$root.authUser.

This way you’re effectively using the root instance as a store.

Hope this helps!

👤Rwd

3👍

Even though answer is accepted and OP found a satisfying solution I think it’s important to suggest using Vuex. It’s a centralized data store that keeps data that can be shared between components. Also allows you to modify data in vuex store from all components in a structured and debugable way which is not possible with accepted solution.

I understand it might be an overkill for OP needs but I still belive it’s a better solution.

Leave a comment