25

The Firebase documentation mentions that the local emulator supports Real and Demo projects. A demo project is defined as:

A demo project has no Firebase console configuration and no live resources. Demo project IDs have the demo- prefix.

The above mentions a demo- prefix but I can't find any examples of how that works. Is it possible to setup a demo project as specified in the above documentation without requiring a Firebase console project or any live resources?

Christian
  • 353
  • 2
  • 6
  • I don't get this either. It sounds like there should be a way to add a demo project with `firebase use --add`. I've tried manually adding a demo project to `.firebaserc` to no avail. – whatsthatitspat Jul 25 '21 at 00:22

1 Answers1

29

You can start the emulators with a demo project by using the --project flag:

$ firebase emulators:start --project demo-test --only auth

Just make sure that the project ID start with the demo- prefix. This line will produce the following output:

i  emulators: Starting emulators: auth
i  emulators: Detected demo project ID "demo-test", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.
Tobias
  • 408
  • 4
  • 5
  • 2
    Do you have to init a project called demo-test first? – Scorb Dec 09 '21 at 17:13
  • 1
    Ow good old google docs... adding this line avoids so much confusion... – PVermeer Dec 13 '21 at 12:02
  • 1
    This works like a charm, but note that you can no longer rely on the default project specified by `firebase use` and you need to specify the demo project on every CLI command (e.g. `firebase functions:shell --project demo-test`) – Johnny Oshika Jun 24 '22 at 16:03
  • 1
    Where do you an API key to initialize the Firebase client library? Do you just make up a random one? – aldel Aug 03 '22 at 13:37
  • @aldel you can use a random one. I prefer to use a string `any` so it's clear that API key can be any non-empty string. Also don't forget to call `useAuthEmulator('localhost', 9099)` in your code. – vogdb Nov 21 '22 at 19:37
  • when i try this my cloud functions break: `functions: Failed to load function definition from source: FirebaseError: HTTP Error: 403, Permission denied on resource project demo-lendus.` but everything else works fine. Any suggestions? – Lucas Rahn Jul 12 '23 at 22:21