-
Notifications
You must be signed in to change notification settings - Fork 2
Firebase Setup
Dae Houlihan edited this page Nov 11, 2024
·
2 revisions
Warning
This section is under construction. Some of this information is out of date with the latest release of the template. Use with caution.
This guide walks you through setting up Firebase for your project.
- Go to Firebase Console
- Click "Add project"
- Enter your project name
- For this example, we'll use
my-experiment
- For this example, we'll use
- Optional: Enable Google Analytics
- Not required for this template
- Click "Create project"
- In Firebase Console:
- Click on "Cloud Firestore"
- Click "Create Database"
- Choose security rules:
- Select "Start in production mode"
- Choose database location:
- Select the region closest to your participants
- Click "Enable"
- In Firebase Console:
- Go to "Authentication"
- Click "Get Started"
- Enable Anonymous auth:
- Click on "Anonymous" provider
- Toggle to "Enable"
- Click "Save"
-
Get your web credentials:
- Go to Project Settings (gear icon)
- Click web icon (
</>
) - Register your app with a nickname
- Enable Firebase Hosting
-
Create configuration file:
- Create
src/firebaseConfig.ts
- Add this code:
- Create
export const firebaseConfig = {
apiKey: "your-api-key",
authDomain: "your-domain",
projectId: "your-project-id",
storageBucket: "your-bucket",
messagingSenderId: "your-sender-id",
appId: "your-app-id"
};
- Update
firestore.rules
:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /sharedData/** {
allow read: if true;
allow write: if request.auth.uid == uid;
}
match /expData/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid;
}
match /userData/{uid} {
allow read: if true;
allow write: if request.auth.uid == uid;
}
}
}
- Deploy the rules:
yarn deploy-rules
- Start development server:
yarn dev
- Open browser console
- Click "init data" button
- Verify data appears in Firestore
- Continue to Development Workflow
- Learn about Data Collection