Skip to content

Commit d0249df

Browse files
committed
docs: note about external services
Close #1327
1 parent 6ec8a6c commit d0249df

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

docs/guide/other-firebase-services.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ const messaging = getMessaging(firebaseApp)
4646
</script>
4747
```
4848

49+
If you find yourself using this very often, you can create a composable for it:
50+
51+
::: code-group
52+
53+
```ts [composables/firebase-messaging.ts]
54+
import { getMessaging } from 'firebase/messaging'
55+
import { useFirebaseApp } from 'vuefire'
56+
57+
export function useFirebaseMessaging() {
58+
return getMessaging(useFirebaseApp())
59+
}
60+
```
61+
62+
```vue [MyComponent.vue]
63+
<script setup>
64+
import { useFirebaseMessaging } from '~/composables/firebase-messaging'
65+
66+
const messaging = useFirebaseMessaging()
67+
</script>
68+
```
69+
70+
:::
71+
4972
In the case of Services that require initialization, you should do it alongside the initialization of the Firebase App:
5073

5174
```ts

0 commit comments

Comments
 (0)