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/guide/getting-started.md
+27-14Lines changed: 27 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,15 +79,14 @@ import App from './App.vue'
79
79
import { firebaseApp } from'./firebase'
80
80
81
81
const app =createApp(App)
82
-
app
83
-
.use(VueFire, {
84
-
// imported above but could also just be created here
85
-
firebaseApp,
86
-
modules: [
87
-
// we will see other modules later on
88
-
VueFireAuth(),
89
-
],
90
-
})
82
+
app.use(VueFire, {
83
+
// imported above but could also just be created here
84
+
firebaseApp,
85
+
modules: [
86
+
// we will see other modules later on
87
+
VueFireAuth(),
88
+
],
89
+
})
91
90
92
91
app.mount('#app')
93
92
```
@@ -102,12 +101,26 @@ const db = useFirestore()
102
101
</script>
103
102
104
103
<template>
105
-
<div>
106
-
...
107
-
</div>
104
+
<div>...</div>
108
105
</template>
109
106
```
110
107
108
+
#### Vue 2
109
+
110
+
VueFire only supports Vue 2.7 and it also requires you to use `createApp()` from `vue-demi` to keep the API the same in both versions, Vue 2 and Vue 3. Here is the same example as above but simplified for Vue 2:
111
+
112
+
```ts{1}
113
+
import { createApp } from 'vue-demi'
114
+
import { VueFire } from 'vuefire'
115
+
import App from './App.vue'
116
+
// the file we created above with `database`, `firestore` and other exports
117
+
import { firebaseApp } from './firebase'
118
+
119
+
const app = createApp(App)
120
+
app.use(VueFire, { firebaseApp })
121
+
app.mount('#app')
122
+
```
123
+
111
124
### Composition API
112
125
113
126
VueFire exposes a few [composables](https://vuejs.org/guide/reusability/composables.html#composables) to create reactive variables from Firebase references.
@@ -129,7 +142,7 @@ const todos = useDatabaseList(dbRef(db, 'todos'))
129
142
<template>
130
143
<ul>
131
144
<li v-for="todo in todos" :key="todo.id">
132
-
<span>{{ todo.text }}</span>
145
+
<span>{{ todo.text }}</span>
133
146
</li>
134
147
</ul>
135
148
</template>
@@ -146,7 +159,7 @@ const todos = useCollection(collection(db, 'todos'))
0 commit comments