Follow this guide to get Firebase setup in your Divjoy codebase. If you've chosen Firebase Auth or Cloud Firestore (or both) then this guide is for you.
Click the ▶︎ icon next to any step to see a detailed walkthrough with screenshots.
Basic Setup
Follow these steps if you're using Firebase Auth or Cloud Firestore
‣
‣
‣
‣
.env
file.‣
‣
private_key
and client_email
values into your codebase .env
file. This is necessary for any server logic that needs to talk to Firebase.Firebase Auth
Follow these steps if you're using Firebase Auth (skip if using a different auth provider)
‣
‣
‣
‣
http://localhost:3000/firebase-action
. This page is automatically inserted by Divjoy when you export your codebase.- Important: If you're using Cloud Firestore then authentication will not work until that is setup. The auth logic we give you in
src/util/auth.js
automatically merges extra user data from Cloud Firestore and will fail if it's unreachable. Continue on to the next section to setup Cloud Firestore.
Cloud Firestore
Follow these steps if you're using Cloud Firestore (skip if using a different database provider).
‣
‣
firestore.rules
file. This ensures that your users cannot read or edit data that they shouldn't have access to.‣
‣
items
collection on the fields owner (ascending)
and createdAt (descending)
. This is required so that your useItemsByOwner
function can properly fetch a user's items and sort by date created. You'll see an example UI that utilizes this database logic in the dashboard page of your codebase.Congrats! Firebase is all setup in your codebase. If you're already running your dev command you'll want to make sure to stop it (Ctrl + C) and re-run it so that it reads your updated
.env
file.FAQ
‣
‣
‣
‣