Skip to content

Commit 45cf4a2

Browse files
committed
docs: minor updates
1 parent 9d7a22a commit 45cf4a2

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

docs/guide/ssr.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,22 @@ Web Security is a broad topic that we cannot cover here. We recommend you to rea
8989

9090
## Usage outside of components
9191

92-
If you are using VueFire composables outside of components, e.g. using `useDocument()` within a [Pinia](https://pinia.vuejs.org) store, you need to manually wait for the data to be loaded on the server as VueFire cannot call `onServerPrefetch()` for you. This means you also need to [use `<Suspense>`](https://vuejs.org/guide/built-ins/suspense.html#suspense) to be able to use `await` within `setup()`. VueFire exposes a function to retrieve all pending promises created by the different composables (`useDocument()`, `useDatabaseObject()`, etc). Await it inside of **any component that uses the data**:
92+
If you are using VueFire composables outside of components, e.g. using `useDocument()` within a [Pinia](https://pinia.vuejs.org) store, you need to manually wait for the data to be loaded on the server as VueFire cannot call `onServerPrefetch()` for you and you will have to manually call it yourself. VueFire exposes a function to retrieve all pending promises created by the different composables (`useDocument()`, `useDatabaseObject()`, etc). You will need to use it inside of **any component that uses the data**:
93+
94+
```vue
95+
<script setup>
96+
import { useQuizStore } from '~/stores/quiz'
97+
import { usePendingPromises } from 'vuefire'
98+
99+
// this store internally calls `useDocument()` when created
100+
const quizStore = useQuizStore()
101+
102+
// `useDocument()` has been called within `useQuizStore()` but this component isn't aware of it
103+
onServerPrefetch(() => usePendingPromises())
104+
</script>
105+
```
106+
107+
While the recommended approach is to use `onServerPrefetch()`, aother possibility is to [use `<Suspense>`](https://vuejs.org/guide/built-ins/suspense.html#suspense) to be able to use `await` within `setup()`:
93108

94109
```vue
95110
<script setup>

docs/nuxt/getting-started.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ npm install nuxt-vuefire
1313
Add it to your nuxt config:
1414

1515
```ts
16-
import { defineNuxtConfig } from 'nuxt/config'
17-
import VueFire from 'nuxt-vuefire'
18-
1916
export default defineNuxtConfig({
20-
modules: [VueFire, {
17+
modules: [
18+
// ... other modules
19+
'nuxt-vuefire',
20+
],
21+
22+
vuefire: {
2123
/* options */
22-
}],
24+
},
2325
})
2426
```

0 commit comments

Comments
 (0)