You have a couple of options for deployment. You can either use Firebase hosting or deploy using Netlify. These are the instructions for Netlify. Firebase instructions are here.
Netlify uses continuous deployment, which means when you push to your deployed branch, Netlify automatically deploys unless you change the settings. This means you can worry less about deploys and get detailed logs about your deploys, which are helpful if the deploy fails. Netlify will also NOT deploy the failed instance and will use the last successful deploy so you don't have to worry about your production app breaking.
- In the ROOT of your application, create a
.env
file - Add
.env
to your.gitignore
file - Place the following in that file with your keys as the values
REACT_APP_API_KEY=XXX
REACT_APP_AUTH_DOMAIN=XXX
REACT_APP_DATABASE_URL=XXX
REACT_APP_PROJECT_ID=XXX
REACT_APP_STORAGE_BUCKET=XXX
REACT_APP_MESSAGING_SENDER_ID=XXX
REACT_APP_APP_ID=XXX
REACT_APP_MEASUREMENT_ID=XXX
- Create
apiKeys.js
in yourhelpers
directory. - Place the following in the file:
const firebaseConfig = {
apiKey: process.env.REACT_APP_API_KEY,
authDomain: process.env.REACT_APP_AUTH_DOMAIN,
databaseURL: process.env.REACT_APP_DATABASE_URL,
projectId: process.env.REACT_APP_PROJECT_ID,
storageBucket: process.env.REACT_APP_STORAGE_BUCKET,
messagingSenderId: process.env.REACT_APP_MESSAGING_SENDER_ID,
appId: process.env.REACT_APP_APP_ID,
measurementId: process.env.REACT_APP_MEASUREMENT_ID,
};
export default firebaseConfig;
- Make sure all your code is pushed up to Github on the branch you want to deploy
- Navigate to https://app.netlify.com/
- Login/Create an account
- Click "New Site from Git"
- Select Github or whichever tool you are using
- Authorize Github if you have not already
- Select the repo that you want to deploy
- Update the settings as are shown below and click Deploy Site
Your deploy should have finished, but you will notice that your site page is empty and there are console errors.
- Navigate to
settings
>deploys
>environment
- Add all the Environment variable keys and values as from your
.env
file as is shown below
- Navigate to
deploys
and select the Trigger Deploy dropdown to redeploy
- In Firebase under Authentication select sign in methods, scroll to Authorized domains. Add your Netlify URL.