Powered by Vite
Also checkout a fork Firebase Composition for Nuxt
<template>
<div>UID: {{ uid }}</div>
<pre>{{ accounts }}</pre>
<button @click="signInWithGoogle">Sign In with Google</button>
<button @click="createAccount({ name: 'Join' })">Add</button>
</template>
<script>
import { initFirebase, useAuth, useCollection, useDoc } from 'vca-firebase'
import firebaseConfig from './firebase.config.js'
export default {
setup() {
initFirebase(firebase, firebaseConfig)
const { uid, signInWithGoogle } = useAuth()
const { docs: accounts } = useCollection('accounts')
const { create: createAccount } = useDoc('accounts')
return {
signInWithGoogle,
uid,
accounts,
createAccount,
}
},
}
</script>
yarn create vite-app test-vca-firebase
cd test-vca-firebase
yarn add firebase
yarn add vca-firebase
Create firebase.config.js
:
config
object in Firebase Console.analytics
.export default {
config: {
apiKey,
authDomain,
databaseURL,
projectId,
storageBucket,
messagingSenderId,
appId,
measurementId,
},
analytics: false,
}
Setup project and run:
yarn dev
See the power of Vite! Project is available in less than 1 second!
Author: razbakov
Source Code: https://github.com/razbakov/vca-firebase
#vue #vuejs #javascript