You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Nuxt-Fire provides helper functions that can generally be accessed like so:
5
+
The nuxt-fire plugin provides helpers for the easy setup of **server-side authentication** via WebTokens and Cookies for Firebase Auth in **Nuxt Universal Mode (SSR)**.
Use the [auth.initialize option](/options/#auth) with at least `onSuccessMutation` and `setAuthCookie = true` defined. Make sure to create the respective mutation that saves the authUser to the state.
12
10
13
-
If the initAuth config is set, nuxt-fire will add two (instead of one) plugins to your Nuxt application:
14
-
**nuxt-fire/plugins/main.js** and **nuxt-fire/plugins/initAuth.js**.
11
+
#### Step 2 - Add the getAuthUserFromCookie() helper
15
12
16
-
If you use initAuth and want another plugin to be called AFTER firebase initialization but BEFORE initAuth gets called, you can use this helper function to move the other plugin inbetween these two.
17
-
18
-
Just add the following to your nuxt.config.js:
13
+
Add the `getAuthUserFromCookie()` helper function as follows to your nuxtServerInit action and commit the authUser object to the mutation defined in step 1.
If the initAuth config is set, nuxt-fire will add two (instead of one) plugins to your Nuxt application:
12
+
**nuxt-fire/plugins/main.js** and **nuxt-fire/plugins/initAuth.js**.
13
+
14
+
If you use initAuth and want another plugin to be called AFTER firebase initialization but BEFORE initAuth gets called, you can use this helper function to move the other plugin inbetween these two.
Copy file name to clipboardExpand all lines: packages/docs/options/README.md
+13-15Lines changed: 13 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -130,8 +130,6 @@ Preloads dynamically loaded services. More information [here](https://webpack.js
130
130
Only applies if `static === false`.
131
131
:::
132
132
133
-
134
-
135
133
#### chunkName
136
134
137
135
Be default, the dynamically imported services are named `vendors.firebase-${serviceName}.js` in development mode, and `[id]` in production mode (`process.env.NODE_ENV === 'production'`). If you want to change this behaviour, you can do so with this option.
This feature is experimental and has not been fully tested for all cases. Use it with care and don't use it in production environemnts. It might get changed completely in future updates. If you have any issues or questions for this feature please feel free to create an issue [here](https://github.com/lupas/nuxt-fire/issues) to help us improve it.
169
-
:::
170
-
171
166
This sets up SSR-ready `onAuthStateChanged()` without any effort.
172
167
173
168
Just add a mutation/action to your vuex store that handles what to do with the authUser object (e.g. save it to the state or get user data from FireStore) and then define the name of the action/mutation in the initAuth configuration as below
The `setAuthCookie = true` option sets a cookie after every `onAuthStateChanged()` trigger. The cookie can be used for server-side authentication as described [here](/advanced/#firebase-auth-in-universal-mode).
191
+
195
192
::: warning
196
193
Do not save `authUser` directly to the store, since this will save an object reference to the state which gets directly updated by Firebase Auth periodically and therefore throws a `vuex` error if `strict != false`.
@@ -269,7 +267,7 @@ More information [here](https://firebase.google.com/docs/functions/locations).
269
267
270
268
Sets up `useFunctionsEmulator("http://localhost:EMULATOR_PORT")` to point to a Cloud Functions emulator running locally instead of the productive one.
271
269
272
-
More information in the official Firebase [API Docs](https://firebase.google.com/docs/reference/android/com/google/firebase/functions/FirebaseFunctions.html#useFunctionsEmulator(java.lang.String)) and [Functions Docs](https://firebase.google.com/docs/functions/local-emulator).
270
+
More information in the official Firebase [API Docs](<https://firebase.google.com/docs/reference/android/com/google/firebase/functions/FirebaseFunctions.html#useFunctionsEmulator(java.lang.String)>) and [Functions Docs](https://firebase.google.com/docs/functions/local-emulator).
0 commit comments