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

vincent15000's avatar

Access a reactive property from inside a pinia store

Hello,

I have an authStore in which I have the authenticated user properties.

const authUser = reactive({});

function setAuthUser(user) {
    authUser.id = user.id;
    authUser.name = user.name;
    authUser.email = user.email;
    authUser.admin = user.admin;
    authUser.manage_branches = user.manage_branches;

    isAuthenticated.value = true;
}

And I use this store in a component.

The use is authenticated.

console.log(authStore.authUser); // I get a proxy object with all right datas about the connected user (id: 1, ...)

console.log(authStore.authUser.id); // I get undefined

Do you have any idea what could be the problem ?

Thanks for your help.

V

0 likes
0 replies

Please or to participate in this conversation.