App Hosting Emulation
You can test your App Hosting setup locally using the Firebase Local Emulator Suite. This allows you to verify your app's behavior with environment variables and secrets before deploying.
Configuration: apphosting.emulator.yaml
This optional file overrides apphosting.yaml settings specifically for the
local emulator. Use it to provide local secret values or override resource
configs. If it contains sensitive values such as API keys, do not commit it to
source control.
# apphosting.emulator.yaml (gitignored usually)
runConfig:
cpu: 1
memoryMiB: 512
env:
- variable: API_KEY
value: "local-dev-api-key" # Override secret with local valueRunning the Emulator
To start the App Hosting emulator:
npx -y firebase-tools@latest emulators:start --only apphostingOr, if you are also using other emulators (Auth, Firestore, etc.):
npx -y firebase-tools@latest emulators:startCapabilities
- Builds your app: Runs the build command defined in your
package.jsonto generate the serving artifact. - Serves locally: Runs the app on
localhost:5004(default). Configurable by settinghostandportin theemulatorsblock offirebase.json, like so:
{
"emulators": {
"apphosting": {
"host": "localhost",
"port": 5004
}
}
}- Env Var Injection: Injects variables defined in
apphosting.yamlandapphosting.emulator.yamlinto the process.