Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Setup Firebas

Tarik Huber edited this page Nov 30, 2017 · 1 revision

After the installation of rmw-shell we need to change the firebase configs so the library know on what Firebase project it has to refer. If you don't provide any configs for Firebase or don't change the default one rmw-shell will fallback to the Firebase React Most Wanted project.

Configs

To setup firebase we have to get our Firebase config data from the Firebase Console. Those we have to save into our src/config.js file. You will notice that we have two Firebase configurations:

const config = {
  firebase_config: {
    apiKey: 'AIzaSyBQAmNJ2DbRyw8PqdmNWlePYtMP0hUcjpY',
    authDomain: 'react-most-wanted-3b1b2.firebaseapp.com',
    databaseURL: 'https://react-most-wanted-3b1b2.firebaseio.com',
    projectId: 'react-most-wanted-3b1b2',
    storageBucket: 'react-most-wanted-3b1b2.appspot.com',
    messagingSenderId: '258373383650'
  },
  firebase_config_dev: {
    apiKey: 'AIzaSyB31cMH9nJnERC1WCWA7lQHnY08voLs-Z0',
    authDomain: 'react-most-wanted-dev.firebaseapp.com',
    databaseURL: 'https://react-most-wanted-dev.firebaseio.com',
    projectId: 'react-most-wanted-dev',
    storageBucket: 'react-most-wanted-dev.appspot.com',
    messagingSenderId: '70650394824'
  },
//...
}

From the name of the properties we can see that one of them is for the production and the other for development. If you don't split your project into prod and dev you can just replace both configs with the configs for your Firebase project. The reason we are splitting those is that every project that goes to production should not be touched by the development. And with Firebase it is very easy to just create a new project that will be your development project. When starting a new project or playing with RMW separated projects are nor a mus but as soon your deploy your project to production you should add a separate development project.

Add your project

We still have to say to the firebase-tools what project to use for deployment. Take sure that you have installed the firebase-toosl globale with the command:

npm i firebase-tools -g

We do this with a simple command:

firebase use --add

When the command is successful you will be prompted to select one of your Firebase projects. You can do so by scrolling with the up and down keys on your keyboard and hitting enter on the project you want. After that you will be prompted to define an alias for your project. If no provided the alias will be default.

IMPORTANT: it is very important to add your project 3 times for the default, dev and prod aliases. If you have separated dev and prod projects you should add the dev project as dev alias and the prod as prod alias. For the default I use always the dev project. To add the project for multiple aliases just run the above command for each alias.

Prepare functions

//TO DO

Clone this wiki locally