question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Firestore data in emulator not showing up in emulator UI

See original GitHub issue

[REQUIRED] Environment info

firebase-tools:

$ firebase --version
8.4.2

$ node -v
v10.16.3

Platform: macOS

[REQUIRED] Test case

index.js

const admin = require('firebase-admin');

process.env.FIRESTORE_EMULATOR_HOST = 'localhost:8080';

admin.initializeApp();

let db = admin.firestore();

async function test() {
    let docRef = db.collection('users').doc('alovelace2');

    let setAda = docRef.set({
        first: 'Ada',
        last: 'Lovelace',
        born: 1815
    });
}

test()

package.json

{
    "name": "firebase-emulator-ui-test",
    "version": "1.0.0",
    "main": "index.js",
    "author": "Chris Hager <chris@linuxuser.at>",
    "license": "MIT",
    "dependencies": {
    "firebase-admin": "^8.12.1"
    }
}

I simply created a new directory, initialise firebase with firebase init and the node project with yarn init, and added firebase-admin (yarn add firebase-admin).

[REQUIRED] Steps to reproduce

  • Run the code above. Adding multiple entries to the firestore works, and I can retrieve them in code.

[REQUIRED] Expected behavior

Firebase UI at http://localhost:4000/firestore should show the data.

[REQUIRED] Actual behavior

Firebase UI at http://localhost:4000/firestore shows only an empty root.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (3 by maintainers)

github_iconTop GitHub Comments

28reactions
metachriscommented, Jun 15, 2020

Found the answer – when calling admin.initializeApp() you need to set the correct projectId, then the data will show up.

27reactions
samtsterncommented, Dec 22, 2020

@charles-allen you’ve got it exactly right. A fake project ID will allow database writes but not much else. If you want to start the Emulator Suite with a fake project ID just do this:

firebase --project="foobar123" emulators:start
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why don't I see data in the Firebase Cloud Firestore Emulator ...
If tests use this project ID, their data is visible in the emulator. If they use some other, tests work but the emulator...
Read more >
Connect your app to the Cloud Firestore Emulator - Firebase
Connect your app to the Cloud Firestore Emulator · Choose a Firebase project · Instrument your app to talk to the emulators ·...
Read more >
The Full Guide on how to use the Firebase Emulator for the Web
Once you added all the data to Firestore if you stop the emulator and start it again, it will start empty, so you'd...
Read more >
Meet the Firestore Emulator Requests Monitor
You can access the Requests Monitor right now from the Emulator UI if you have the latest Firebase CLI running. (If not, it's...
Read more >
Firebase Emulators Setup - Tips to overcome trouble, hurdles ...
It is possible, being busy with hooking up your frontend to the firestore emulator host, you accidently have terminated your terminal, expecting ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found