Skip to content
20 changes: 20 additions & 0 deletions docs/firebase.md
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,23 @@ app:
Open the web app by visiting the URL printed by the `deploy` command. The app
requires you to sign in with a Google account, after which you can initiate
endpoint requests.

## Developing using Firebase Local Emulator Suite

Firebase offers a [suite of emulators for local development](https://firebase.google.com/docs/emulator-suite), which you can use with Genkit.

To use Genkit with the Firebase Emulator Suite, start the the Firebase emulators like this:

```bash
GENKIT_ENV=dev firebase emulators:start --inspect-functions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sufficient? I've got the following:

"serve-genkit": "npm run build && GENKIT_ENV=dev GENKIT_REFLECTION_ON_STARTUP_FAILURE=ignore firebase emulators:start --inspect-functions"

I haven't tried which is the absolute essential number of parameters to make it work...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We made a few changes, GENKIT_REFLECTION_ON_STARTUP_FAILURE is not necessary now.

```

This will run your code in the emulator and run the Genkit framework in development mode, which launches and exposes the Genkit reflection API (but not the Dev UI).

Then, launch the Genkit Dev UI with the `--attach` option to connect it to your code running inside the Firebase Emulator:

```bash
genkit start --attach http://localhost:3100 --port 4001
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have

"genkit-emulator": "GCLOUD_PROJECT=fir-genkit-fundamental-01 && genkit start --attach http://localhost:3100 --port 4444",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In attach mode runtime env var (e.g. GCLOUD_PROJECT) are not required.

```

To see traces from Firestore in the Dev UI you can navigate to the Inspect tab and toggle the "Dev/Prod" switch. When toggled to "prod" it will be loading traces from firestore.