How to use Pinia with Firebase 9 onAuthStateChanged? #1053
Unanswered
BenJackGill
asked this question in
Help and Questions
Replies: 2 comments
-
I know my answer is late, but for those who want to use firebase with pinia, you can take these videos as inspiration: https://www.youtube.com/watch?v=Kc-FbPSdezg https://www.youtube.com/watch?v=xceR7mrrXsA I can even use the explanation for this react video applying it to pinia |
Beta Was this translation helpful? Give feedback.
0 replies
-
Another approach: In
In the user store:
To persist user state to local storage (works with SSR), install the Pinia Persisted State plugin for Nuxt: https://github.com/prazdevs/pinia-plugin-persistedstate |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using Firebase 9 in my Vue 3 / Quasar / TypeScript app.
I am trying to fetch a user object from Firebase 9 using the
onAuthStateChanged
method, storing it in a ref, and then using that in my Piniauser
store.This is the
getUser.ts
composable I use to get the user from Firebase:And this is my Pinia store named
user.ts
:The
user.value
inside onAuthStateChanged correctly populates with the Firebase user object.But the
user.value
ref inside the Pinia store always returns null.What am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions