firebase / firebase/firebase-tools
Improve documentation for using "demo-" projects with the emulator
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.3k
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 84
Description
## Edit
See the first comment I left below. I found a bug in the Dart SDK, so I don't think there's actually an issue in the emulator. That said, I think the docs can definitely be improved. Take a look at the comment for details.
## Original Copy
All of the [emulator documentation pages](https://firebase.google.com/docs/emulator-suite/connect_auth) mention that the emulator supports demo projects, which are projects prefixed with "demo-". This type of project is recommended since the application will not attempt to connect to production services that are not running in the emulator.
The problem is that there appears to be no other documentation explaining how to use demo projects with the emulator, and they don't seem to work out of the box. There are several other issues mentioning trouble using demo projects with the emulator:
- https://github.com/firebase/firebase-tools/issues/2365
- https://github.com/firebase/firebase-tools-ui/issues/482
- https://github.com/firebase/firebase-tools/issues/5218
- https://github.com/googleapis/google-cloud-java/issues/13141
There are a few problems:
1. There are no clear instructions about how to use a demo project with the emulator. It seems that launching the project with an explicit project name (i.e. `firebase emulators:start --project demo-app`) is required since `firebase use` does not provide a way to set a demo project.
2. When I launch the emulator with `firebase emulators:start --project demo-app`, I can't see any data in the emulator's Firestore web ui. The app is able to connect to it though because updates are posted to the "requests" tab, and the data is persisted across app restarts even with persistence disabled in the SDK.
3. For Flutter at least, it's unclear how the application should be configured and what the effect of the configuration is. There's a `demoProjectId` argument to `Firebase.initializeApp()`, but the app is able to connect to the emulator regardless of whether that's specified.
## Action Items
1. Please reopen https://github.com/firebase/firebase-tools/issues/2365. It seems to be a real bug, or at least a usage issue that could use a better explanation somewhere.
2. Please add documentation explaining how to use demo projects with the emulator. The current docs say that using a demo project is recommended, but there's no explanation of how to do it and I haven't been able to figure it out after several hours of trying. Is it just a matter of configuring the application to use a `demo-` prefixed project id? Do we need to configure anything for the emulator itself?
EDIT: It looks like https://github.com/firebase/codelab-friendlychat-android/pull/173 configures a demo project id in one of the Firebase codelabs. In that codelab, the emulator is also launched with the demo project id.
So I think the main questions are:
1. Why is the application able to connect using `demo-app` as the project id if the emulator is launched with a different project id?
2. Why isn't any data visible in the Firestore web UI when `demo-app` is used as the project id (https://github.com/firebase/firebase-tools/issues/2365).
@samtstern I think you updated the codelab. Do you have any advice?
## Standard Info
### Environment info
`firebase --version` 14.12.1
**firebase-tools:** emulator
**Platform:** flutter
### Test case
1. Create a flutter project
2. flutterfire configure
3. In your flutter code, initialize Firebase with `await Firebase.initializeApp(demoProjectId: 'demo-project');`
4. Launch the emulator with `firebase emulators:start --project demo-project`
5. The app will be able to communicate with the emulator, but none of the datat will appear in the emulator's Firestore web ui.
### Steps to reproduce
The steps are listed in the test case.
### Expected behavior
The data should be visible in the emulator web ui.
### Actual behavior
No data is listed in the emulator web ui.
Contributor guide
Assessment
This issue has not been assessed yet.