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
There are multiple ways to add the auth providers to your app like exporting a `new GoogleAuthProvider()` instance from the file where we initialize Firebase. Another way is to create it directly in the component where you need it. make sure to add it into a regular `<script>` since each `<script setup>` is scoped to a component instance:
84
84
85
85
```vue{1-4,17}
86
-
<script lang="ts">
86
+
<script>
87
87
import { GoogleAuthProvider } from 'firebase/auth'
88
88
export const googleAuthProvider = new GoogleAuthProvider()
89
89
</script>
@@ -131,16 +131,18 @@ There is also a `getCurrentUser()` function that returns a promise of the curren
131
131
132
132
```ts
133
133
router.beforeEach(async (to) => {
134
-
// routes with `meta: { requiresAuth: true }` will check for the users, others won't
134
+
// routes with `meta: { requiresAuth: true }` will check for
135
+
// the users, others won't
135
136
if (to.meta.requiresAuth) {
136
137
const currentUser =awaitgetCurrentUser()
137
138
// if the user is not logged in, redirect to the login page
138
139
if (!currentUser) {
139
140
return {
140
141
path: '/login',
141
142
query: {
142
-
// we keep the current path in the query so we can redirect to it after login
143
-
// with `router.push(route.query.redirect || '/')`
143
+
// we keep the current path in the query so we can
Copy file name to clipboardExpand all lines: docs/guide/realtime-data.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -386,3 +386,9 @@ const todoList = useDocument(
386
386
})
387
387
)
388
388
```
389
+
390
+
::: warning
391
+
392
+
While you can return pretty much anything in `withConverter()`, **if you are using [SSR](./ssr.md)**, make sure you object is serializable. For example, you can't return custom classes or functions.
Note that by default, vite-ssg (used by Vitesse) uses `JSON.stringify()` to serialize the state, which is faster but doesn't support some values like `Date` objects and also exposes your application to some attacks **if your data comes from the user**. You can use a custom `transformState` function to handle this:
74
+
Note that by default, vite-ssg (used by Vitesse) uses `JSON.stringify()` to serialize the state, which is faster but doesn't support some values like `TimeStamp` and `GeoPoint` objects and also exposes your application to some attacks **if your data comes from the user**. You can use a custom `transformState` function to handle this:
Copy file name to clipboardExpand all lines: docs/nuxt/auth.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,19 @@
1
1
# Authentication
2
2
3
-
Nuxt VueFire integrates with [Firebase Authentication](https://firebase.google.com/docs/auth) module to automatically synchronize the current user state on the server and the client.
3
+
Nuxt VueFire integrates with [Firebase Authentication](https://firebase.google.com/docs/auth) module to automatically synchronize the current user state on the server and the client. Activate this module by setting the `vuefire.auth` to `true` in `nuxt.config.ts`:
4
+
5
+
```ts{5}
6
+
export default defineNuxtConfig({
7
+
// ...
8
+
vuefire: {
9
+
// ensures the auth module is enabled
10
+
auth: true,
11
+
config: {
12
+
// ...
13
+
}
14
+
},
15
+
})
16
+
```
4
17
5
18
You can access the current user with the `useCurrentUser()` composable within any component:
If you are using the [Authentication](https://firebase.google.com/docs/auth) module or [AppCheck](https://firebase.google.com/docs/app-check), make sure to enable them as well:
0 commit comments