File tree Expand file tree Collapse file tree 4 files changed +47
-7
lines changed
Expand file tree Collapse file tree 4 files changed +47
-7
lines changed Original file line number Diff line number Diff line change 1+ # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2+ # Firebase Config.
3+ #
4+ # 1. Create firestore database.
5+ # 2. Set the `firebaseConfig` variable.
6+ #
7+ # @see https://firebase.google.com/docs/firestore/quickstart#create
8+ # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
9+ VITE_FIREBASE_API_KEY =
10+ VITE_FIREBASE_AUTH_DOMAIN =
11+ VITE_FIREBASE_PROJECT_ID =
12+ VITE_FIREBASE_STORAGE_BUCKET =
13+ VITE_FIREBASE_MESSAGING_SENDER_ID =
14+ VITE_FIREBASE_APP_ID =
Original file line number Diff line number Diff line change 11# Example
22
3- ```
4- npm install --ignore-scripts
5- npm run dev
6- ```
3+ 1 . Create firestore database as per [ docs] ( https://firebase.google.com/docs/firestore/quickstart#create ) .
4+ 1 . Set environment variables:
5+
6+ ``` sh
7+ # Copy the template .env file to local .env file
8+ cp .env .env.local
9+ # Edit .env.local with firebase config.
10+ ```
11+
12+ 1 . Install dependencies (ideally in project root):
13+
14+ ``` sh
15+ npm install
16+ ```
17+
18+ > If you are running the command directly in the ` examples/firebase ` directory, use ` --ignore-scripts ` .
19+
20+ 1 . Run local dev server:
21+
22+ ``` sh
23+ npm run dev
24+ ```
Original file line number Diff line number Diff line change 11{
22 "name" : " react-query-subscription-firebase-example" ,
33 "private" : true ,
4+ "engines" : {
5+ "npm" : " >=8"
6+ },
47 "version" : " 0.0.0" ,
58 "scripts" : {
69 "dev" : " vite" ,
Original file line number Diff line number Diff line change @@ -11,10 +11,15 @@ import { getFirestore } from 'firebase/firestore';
1111 * @see https://firebase.google.com/docs/firestore/quickstart#create
1212 */
1313const firebaseConfig = {
14- // add config here
14+ apiKey : import . meta. env . VITE_FIREBASE_API_KEY ,
15+ authDomain : import . meta. env . VITE_FIREBASE_AUTH_DOMAIN ,
16+ projectId : import . meta. env . VITE_FIREBASE_PROJECT_ID ,
17+ storageBucket : import . meta. env . VITE_FIREBASE_STORAGE_BUCKET ,
18+ messagingSenderId : import . meta. env . VITE_FIREBASE_MESSAGING_SENDER_ID ,
19+ appId : import . meta. env . VITE_FIREBASE_APP_ID ,
1520} ;
16- if ( Object . keys ( firebaseConfig ) . length === 0 ) {
17- throw new Error ( 'Configure firebase in `src/firebase.ts `' ) ;
21+ if ( Object . values ( firebaseConfig ) . filter ( Boolean ) . length === 0 ) {
22+ throw new Error ( 'Configure env variables in .env.local `' ) ;
1823}
1924
2025export const firebaseApp = initializeApp ( firebaseConfig ) ;
You can’t perform that action at this time.
0 commit comments