Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUsing auth.onAuthStateChanged() in default export #545
Comments
This is not related to Vuefire, but I'm interested in adding it to the cookbook if anybody did Firebase authentication + SSR |
If needed I can deliver some source files. My SSR setup seems pretty complex. |
This article was quite helpful when I was implementing this earlier: https://dev.to/gautemeekolsen/vue-guard-routes-with-firebase-authentication-f4l |
Hello,
I'm trying to delay the execution of my App until Firebase receives the Auth status before my "not logged in"-redirections take place. Afaik this is usually done with:
auth.onAuthStateChanged((user) => {
new Vue()
})
But in my current Vue setup my Vue instance get called in a total different way, which gives me a tough time.
// we should return factory for SSR (runInNewContext: false) export default context => { const store = createStore(context), router = createRouter(context); sync(store, router); return new Vue({ i18n, store, router, ...app }); };
I tried encapsulating new Vue to a const, and turn this constant inside the onAuthStateChanged function. Didn't work. Inside the export default neither. Around the return new Vue neither.
Can someone give me a hint? I already killed hours on this simple task :/
P.S. I'm working with SSR.