Easily integrate Firebase into your Nuxt project.
Make sure you have the newest versions of Nuxt and Firebase installed and setup in your project.
yarn add nuxt # OR npm i nuxt
yarn add firebase # OR npm i firebase
Install the module via NPM or Yarn:
yarn add @nuxtjs/firebase # OR npm i @nuxtjs/firebase
Add the following to your nuxt.config.js.
See all configuration options here.
modules: [
[
'@nuxtjs/firebase',
{
config: {
apiKey: '<apiKey>',
authDomain: '<authDomain>',
databaseURL: '<databaseURL>',
projectId: '<projectId>',
storageBucket: '<storageBucket>',
messagingSenderId: '<messagingSenderId>',
appId: '<appId>',
measurementId: '<measurementId>'
},
services: {
auth: true // Just as example. Can be any other service.
}
}
]
],
Now you can use all Firebase services with this.$fireAuth
, this.$fireStore
, this.$fireMess
etc. (see list here).
Example:
try {
await this.$fireAuth.createUserWithEmailAndPassword('foo@foo.foo', 'test')
} catch (e) {
handleError(e)
}
There is much more options to this simple setup, check out our full documentation below:
MIT - Nuxt-Community - Pascal Luther