Skip to content

What's the deal with useFirestoreEmulator? #4531

Answered by sam-gc
akauppi asked this question in Q&A
Discussion options

You must be logged in to vote

For the emulator functions, this was a conscious decision to have free-floating functions to configure the emulator (so that these don't impact the bundle size when you're not using the emulator). So you'd use (initializeFirestore OR getFirestore) AND useFirestoreEmulator. As with the old version, make sure the emulator function is called before the library is used.

For example:

import { getFirestore, useFirestoreEmulator } from 'firebase/firestore';
const firestore = getFirestore(app);
useFirestoreEmulator(firestore, 'localhost', 8080);

(The difference between initializeFeature and getFeature is that the former allows for more custom configuration of dependencies, whereas the latter pull…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@akauppi
Comment options

@sam-gc
Comment options

sam-gc Feb 25, 2021
Collaborator

Answer selected by akauppi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants