How to connect store/index.js
See original GitHub issueNot found $fireAuth
nuxtServerInit({ dispatch }) {
const user = this.$fireAuth.currentUser
dispatch('auth/setUser', user)
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:15 (7 by maintainers)
Top Results From Across the Web
How can I access react redux state in index.js file?
js file : import React from 'react'; import ReactDOM from 'react-dom'; import './index. css'; import App from './App'; import * as ...
Read more >Is it possible to access my redux store in App/index.js? #1778
I'm pretty sure there is a better and more elegant solution to this but in the mean time you could get the store...
Read more >How To Manage State in a Vue.js Application with Vuex
Open your text editor and in your store/index.js file, initialize your Vuex store. To do this, you need to leverage the createStore function ......
Read more >Configuring Your Store - Redux
First, let's look at the original index.js file in which we created our store: import React from 'react' import { render } from...
Read more >Managing multiple store modules with Vuex - LogRocket Blog
To setup Vuex using npm or yarn, create a store folder in the root of your src folder and create a file in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey guys
As you can see in the example in nuxt-fire-demo both ctx and this should actually work.
@ruslanraupoff Let us know if both options don’t work, then something with your vuex store setup might be wrong.
I don’t know what the issue with the nuxtServerInit was, but this.$fireAuth.currentUser on server-side twill never return currentUser, the currentUser object will always be null on server-side.
If you want to make that work, you would have to work with session cookies or service workers. Read here: https://medium.com/@hiranya911/firebase-introducing-session-cookies-for-server-side-web-apps-fb46cce40b2
The onAuthStateChanged approach will be easier. Here I would suggest you to create a nuxt.js plugin that gets executed on client-side only (no-ssr: true), you can follow the tutorial here: https://hackernoon.com/vue-nuxt-firebase-auth-database-ssr-example-tutorial-facebook-login-setup-authentication-starter-app-a6dfde0133fc
Hope that helps.
This is a generic firebase & nuxt topic and not a nuxt-fire related issue anymore though, so I’ll close this issue for now.