[Vuejs]-How to manage user state in Firebase authentication within a SSR Nuxt.js application?

4๐Ÿ‘

I was able to solve this problem by using the following:

  • Express server โ€“ using axios posts to manage the login on receiving
    the request save the user ID in the session and save the access token
    in a cookie
  • Vuex โ€“ store user state so easily accessible within my Nuxt application
  • Nuxt server middleware โ€“ used to check the authentication status of
    the user on the server. Looking for user ID in the session or the
    access token in a cookie that would have been created on login

Access to the code containing a working, running example of this scenario can be found in this GitHub repository.

I have also written a more detailed blog entry regarding all the important files used in the project.

๐Ÿ‘คRoss

Leave a comment