Skip to content

Commit 83bc879

Browse files
Update emulators.md #3308 (#3521)
* Update emulators.md Added emulator startup information and clarified the environment.useEmulators. Updated the localhost address * Update emulators.md minor update to providers path --------- Co-authored-by: starimploie <[email protected]>
1 parent c415586 commit 83bc879

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

docs/compat/emulators/emulators.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,21 @@ Follow the instructions to download whatever emulator you want to use then check
6060
}
6161
```
6262

63+
Then launch the emulators by running
64+
65+
```shell
66+
firebase emulators:start
67+
```
68+
69+
Then you can visit
70+
71+
```shell
72+
┌─────────────────────────────────────────────────────────────┐
73+
│ ✔ All emulators ready! It is now safe to connect your app. │
74+
│ i View Emulator UI at http://127.0.0.1:4000/ │
75+
└─────────────────────────────────────────────────────────────┘
76+
```
77+
6378
## Import the DI Tokens at your AppModule
6479

6580
Configuring your app to connect to local emulators is easily done by using dependency injection tokens provided by the library. However, there are slighty changes between 6.0.0 and 6.1.0 in the way it was done.
@@ -68,6 +83,17 @@ Configuring your app to connect to local emulators is easily done by using depen
6883

6984
Each module (database, firestore, auth, function) provides `USE_EMULATOR` token to configure the emulator `host` and `port` by passing a tuple of `[string, number]` values, which are set by default to `localhost` and the asigned port from your `firebase.json` file.
7085

86+
Update your `environment.ts` file:
87+
88+
```ts
89+
export const environment = {
90+
production: false,
91+
useEmulators: true,
92+
...
93+
}
94+
95+
```
96+
7197
Import these tokens at your `app.module.ts` as follow:
7298

7399
```ts
@@ -80,7 +106,7 @@ import { USE_EMULATOR as USE_FUNCTIONS_EMULATOR } from '@angular/fire/compat/fun
80106
// ... Existing configuration
81107
providers: [
82108
// ... Existing Providers
83-
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099] : undefined },
109+
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['http://localhost', 9099] : undefined },
84110
{ provide: USE_DATABASE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9000] : undefined },
85111
{ provide: USE_FIRESTORE_EMULATOR, useValue: environment.useEmulators ? ['localhost', 8080] : undefined },
86112
{ provide: USE_FUNCTIONS_EMULATOR, useValue: environment.useEmulators ? ['localhost', 5001] : undefined },
@@ -131,4 +157,4 @@ import { SETTINGS as FIRESTORE_SETTINGS } from '@angular/fire/compat/firestore';
131157
export class AppModule { }
132158
```
133159

134-
For older versions, please upgrade your app to latest version to get the advantages of these new features :rocket:
160+
For older versions, please upgrade your app to latest version to get the advantages of these new features :rocket:

0 commit comments

Comments
 (0)