Question: I want to test locally my firebase functions.
These functions make firestore queries.

So i start the emulator `firebase emulators:start` and in my client i use `firebase.functions().useFunctionsEmulator('http://localhost:5001')`.

My functions work well when i call them in my client. I can read/write data inside the firestore emulator.

The problem :

I want to read the firestore emulator data directly inside my client, like :

```
firebase.firestore().collection('tests').get().then(tests => {
    console.log( tests.docs.map(test=>test.map) )
})

```

but i can't find how to set the firestore emulator inside my client.

here what i tried:

1) Firestore setting

```
firebase.firestore().settings({
    host:'http://localhost:8080',
    ssl:false
})

```

result :

i get `@firebase/firestore: Firestore (6.3.5): Could not reach Cloud Firestore backend. Backend didn't respond within 10 seconds.` inside my client console.

The http request returns 'Not found'

2) Set the emulator url inside my firebaseConfig

```
var firebaseConfig = {
    // ...
    databaseURL: "http://localhost:8080",
    // ...
}

firebase.initializeApp(firebaseConfig)

```

in this case, the remote server (<https://firestore.googleapis.com.>.) is requested.

So i want to setup one of these two cases :

1) Using the remote firestore inside my functions emulators

OR

2) Using the local firestore emulator inside my client code.

Anyone has already done this ?

Answer: 
Ok i found how to do it :

1) launch the functions emulator locally:

```
set GOOGLE_APPLICATION_CREDENTIALS=./privatekey.json && firebase serve --only functions

```

2) then client side:

```
if (process.env.NODE_ENV === 'development') {
    firebase.functions().useFunctionsEmulator('http://localhost:5001')
}

```
**Define the FIRESTORE\_EMULATOR\_HOST environment variable**

If you are using a library that supports the FIRESTORE\_EMULATOR\_HOST environment variable, run:

> 
> export FIRESTORE\_EMULATOR\_HOST=localhost:8080
> 
> 
> 

or just add *FIRESTORE\_EMULATOR\_HOST=localhost:8080* to your .env file