question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to connect store/index.js

See original GitHub issue

Not found $fireAuth

nuxtServerInit({ dispatch }) {
     const user = this.$fireAuth.currentUser
     dispatch('auth/setUser', user)
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
lupascommented, Oct 19, 2019

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.

0reactions
lupascommented, Oct 22, 2019

I change code after refresh page does not work get the currentUser or onAuthStateChanged store/index.js …

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found