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

alexcanana's avatar

Passing the logged in User data to Vue component

Hello,

I have a Vue component that's made of various "sub" Components. I need to pass the logged in User data to one of these sub Component. Of course the user can be logged in or not.

How would you achieve that?

I tried to use a prop on my main Component, but it didn't seem to work. Here's what I did:

<main-component :user="{{ Auth::check() ? Auth::user() : '' }}"></main-component>

Thanks in advance!

0 likes
3 replies
edoc's avatar
<main-component
    @if(auth()->check())
        :user="{{ auth()->user() }}"
    @endif
>
</main-component>
1 like
alexcanana's avatar

Awesome, thank you Edoc!

Is there any way to pass this to the root Vue instance and then to the components that would need the user? Make it a little more reusable?

Thanks!

1 like
eugenefvdm's avatar

@alexcanana

Is there any way to pass this to the root Vue instance

I'm also battling with this. I don't think there is a "standard" way to pass this, but perhaps the Laravel community has a "best practices" way?

Then also, with regards to the passing of the data, how do you "receive" it again on the VueJS component side?

Also what is the command to pay just a few properties, and not the whole shebang for example the password?

Please or to participate in this conversation.