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
Copy file name to clipboardExpand all lines: docs/cookbook/migration-v2-v3.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,17 +17,17 @@ Terms starting with _rtdb_ are now prefixed with _database_ to match the Firebas
17
17
18
18
The `firestorePlugin` and `rtdbPlugin` are now deprecated in favor of _modules_. They are still available but will be removed in the next major version. You should use `VueFire`, `VueFireFirestoreOptionsAPI` and `VueFireDatabaseOptionsAPI` instead:
Note you will still have to follow the [Firebase API](https://firebase.google.com/docs/firestore/manage-data/structure-data) (e.g. `addDoc()`, `updateDoc()`, etc) to update the data.
26
+
Note you will still have to follow the [Firebase API](https://firebase.google.com/docs/firestore/manage-data/structure-data) (e.g. `addDoc()`, `updateDoc()`, etc) to update the data and you will also need [to wait for the data to be loaded on the server](../guide/ssr.md#usage-outside-of-components).
Copy file name to clipboardExpand all lines: docs/guide/getting-started.md
+19-8Lines changed: 19 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,12 +6,22 @@ Before using VueFire, make sure you have a Firebase account and a project setup
6
6
7
7
In order to get started make sure to install the latest version of `vuefire` as well as `firebase`:
8
8
9
-
```sh
9
+
::: code-group
10
+
11
+
```sh [pnpm]
12
+
pnpm i vuefire firebase
13
+
```
14
+
15
+
```sh [yarn]
10
16
yarn add vuefire firebase
11
-
# or
12
-
npm install vuefire firebase
13
17
```
14
18
19
+
```sh [npm]
20
+
npm i vuefire firebase
21
+
```
22
+
23
+
:::
24
+
15
25
::: warning
16
26
17
27
VueFire requires Firebase JS SDK >= 9 but **is compatible with Vue 2 and Vue 3**.
@@ -71,7 +81,7 @@ Note that we will refer to `database` and `firestore` as `db` in examples where
71
81
72
82
First, install the VueFire Vue plugin. It will allow you to add extra modules like [AppCheck](./app-check.md) or [Auth](./auth.md) to your app.
73
83
74
-
```ts
84
+
```ts{2,8-15}
75
85
import { createApp } from 'vue'
76
86
import { VueFire, VueFireAuth } from 'vuefire'
77
87
import App from './App.vue'
@@ -93,10 +103,9 @@ app.mount('#app')
93
103
94
104
This will give you access to some [convenient composables](./firebase-composables.md) like `useFirebaseApp()`, `useFirestore()` and `useDatabase()` in your components:
95
105
96
-
```vue
106
+
```vue{2-3}
97
107
<script setup>
98
108
import { useFirestore } from 'vuefire'
99
-
100
109
const db = useFirestore()
101
110
</script>
102
111
@@ -216,27 +225,29 @@ VueFire can also be used with the Options API, while less flexible, it's still a
216
225
217
226
<FirebaseExample>
218
227
219
-
```js
228
+
```js{2,7-10}
220
229
import { createApp } from 'vue'
221
230
import { VueFire, VueFireDatabaseOptionsAPI } from 'vuefire'
222
231
223
232
const app = createApp(App)
224
233
app.use(VueFire, {
225
234
// ...
226
235
modules: [
236
+
// Add any modules you want to use here
227
237
VueFireDatabaseOptionsAPI(),
228
238
],
229
239
})
230
240
```
231
241
232
-
```js
242
+
```js{2,7-10}
233
243
import { createApp } from 'vue'
234
244
import { VueFire, VueFireFirestoreOptionsAPI } from 'vuefire'
@@ -239,7 +245,7 @@ Given some _users_ with _documents_ that are being viewed by other _users_. This
239
245
240
246
```js
241
247
{
242
-
name:'Jessica',
248
+
name:'Claire',
243
249
documents: [
244
250
// The document is stored somewhere else. Here we are only holding a reference
245
251
doc(collection(db, 'documents'), 'gift-list'),
@@ -263,22 +269,22 @@ In the example above, `documents` is an array of References. Let's look at the d
263
269
264
270
```js
265
271
{
266
-
name:'Jessica',
272
+
name:'Claire',
267
273
documents: [
268
274
{
269
275
content:'...',
270
276
sharedWith: [
271
277
{
272
-
name:'Alex',
278
+
name:'Chris',
273
279
documents: [
274
-
'documents/alex-todo-list',
280
+
'documents/chris-todo-list',
275
281
]
276
282
},
277
283
{
278
-
name:'Robin',
284
+
name:'Leon',
279
285
documents: [
280
-
'documents/robin-todo-list',
281
-
'documents/robin-book',
286
+
'documents/leon-todo-list',
287
+
'documents/leon-book',
282
288
],
283
289
},
284
290
],
@@ -287,7 +293,7 @@ In the example above, `documents` is an array of References. Let's look at the d
287
293
}
288
294
```
289
295
290
-
`documents.sharedWith.documents` end up as arrays of strings. Those strings are actually _paths_ that can be passed to `doc()` as in `doc(db, 'documents/robin-book')` to get the actual reference to the document. By being a string instead of a Reference, it is possible to display a bound document with VueFire as plain text.
296
+
`documents.sharedWith.documents` end up as arrays of strings. Those strings are actually _paths_ that can be passed to `doc()` as in `doc(db, 'documents/leon-book')` to get the actual reference to the document. By being a string instead of a Reference, it is possible to display a bound document with VueFire as plain text.
291
297
292
298
It is possible to customize this behavior by providing a [`maxRefDepth` option](../api/interfaces/UseDocumentOptions.md#maxrefdepth):
You can exclude data from hydration by passing `false` to the `ssrKey` option:
157
+
You can exclude data from hydration by passing `false` to the `ssrKey` option. This is useful when there is no point in waiting for the data to be fetched on the server, e.g. when the data is not being rendered on the server.
157
158
158
159
```ts
159
160
useDocument(..., { ssrKey: false })
160
161
useDatabaseList(..., { ssrKey: false })
161
162
// etc
162
163
```
163
164
165
+
This only works if you avoid rendering on server these documents or collections. **If still render them on server, you will get a hydration error on client**.
166
+
164
167
<!-- TODO: I wonder if we could attach effect scopes to applications so `onServerPrefetch()` is still awaited when attached -->
Copy file name to clipboardExpand all lines: docs/nuxt/deployment.md
+9-3Lines changed: 9 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,16 +20,18 @@ defineNuxtConfig({
20
20
21
21
The Spark plan is a free plan that enable most of firebase functions. With this plan, you want to **prerender your app and deploy it as a static site**. In order to do this, make sure **not to apply the Firebase preset** when bundling your app and to use the `generate` command:
22
22
23
-
```bash
23
+
```sh
24
24
nuxt generate
25
25
```
26
26
27
27
You can then let your CI deploy your app to Firebase or do it manually:
28
28
29
-
```bash
29
+
```sh
30
30
firebase deploy
31
31
```
32
32
33
+
Make sure you **don't have** a `nitro.preset` option set in your `nuxt.config.ts` file.
34
+
33
35
## Blaze plan
34
36
35
37
::: warning
@@ -38,6 +40,10 @@ The Firebase preset is still experimental. It is not recommended to use it in pr
38
40
39
41
The Blaze plan is a pay-as-you-go that allows you to run Firebase Functions. It's free up to a certain amount of requests. With this plan, you can either do the same as with the [Spark plan](#spark-plan) (cheaper) or build with the Firebase preset and deploy your app as a serverless function:
40
42
41
-
```bash
43
+
```sh
42
44
NITRO_PRESET=firebase nuxt build
43
45
```
46
+
47
+
### Route Rules
48
+
49
+
On top of prerendering any routes, you can also use [the `routeRules` option](https://nuxt.com/docs/api/configuration/nuxt-config#routerules-1) to apply any headers like cache options, redirects or even static rendering.
Copy file name to clipboardExpand all lines: docs/nuxt/getting-started.md
+35-4Lines changed: 35 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,40 @@ The Nuxt VueFire module is still a work in progress and it might contain breakin
6
6
7
7
## Installation
8
8
9
-
```bash
9
+
::: code-group
10
+
11
+
```sh [pnpm]
12
+
pnpm install vuefire nuxt-vuefire firebase
13
+
```
14
+
15
+
```sh [yarn]
16
+
yarn add vuefire nuxt-vuefire firebase
17
+
```
18
+
19
+
```sh [npm]
10
20
npm install vuefire nuxt-vuefire firebase
11
21
```
12
22
23
+
:::
24
+
13
25
Additionally, if you are using [SSR](https://nuxt.com/docs/api/configuration/nuxt-config/#ssr), you need to install `firebase-admin` and its peer dependencies:
Next, add `nuxt-vuefire` to the `modules` section of `nuxt.config.js` and configure it with the credentials created in your app settings in your project overview (`https://console.firebase.google.com/project/YOUR_PROJECT_NAME/overview)`. You can find more details [in Firebase Documentation](https://firebase.google.com/docs/web/setup#create-project). It should look something like this:
If you are using SSR with any auth related feature, you will need to create a [service account](https://firebase.google.com/support/guides/service-accounts) and provide its content as an _environment variable_ named `GOOGLE_APPLICATION_CREDENTIALS`.
43
69
44
70
In local development it's more convenient to put the `service-account.json` file alongside other files and refer to its path in the environment variable:
This service account file contains sensitive information and should **not be committed to your repository**.
77
+
This service account file contains sensitive information and should **not be committed to your repository**. Make sure to exclude it from your version control system:
0 commit comments