|
2 | 2 |
|
3 | 3 | ## Before you begin |
4 | 4 |
|
5 | | -- **Firebase CLI.** Setup uses the Firebase CLI (`firebase-tools`), version 14 or newer. `ng add` installs it if it is missing and prompts you to sign in, so you do not have to install it yourself first. It does not upgrade a copy you already have, so an older one stops setup with `firebase-tools version 14.0.0+ is required, please upgrade and run again`. To handle it ahead of time, or to clear that error, run `npm install -g firebase-tools` then `firebase login`. |
6 | | -- **On the newest Angular major, use `@next`.** If `ng add @angular/fire` reports an Angular peer-dependency conflict, your Angular version is newer than AngularFire's default (`latest`) release. Install the version-matched pre-release instead: `ng add @angular/fire@next`. |
| 5 | +- **Firebase CLI** |
| 6 | + - Setup uses the Firebase CLI (`firebase-tools`). Install version 14 first, with `npm install -g firebase-tools@14`, then `firebase login`. |
| 7 | + - With no CLI on the machine, `ng add` installs the newest version for you, and on version 15 setup stops right after the features question with `Cannot read properties of undefined (reading 'email')` (#3768). |
| 8 | + - A copy older than 14 stops setup with `firebase-tools version 14.0.0+ is required, please upgrade and run again`, and `ng add` does not upgrade a copy you already have. |
7 | 9 | - **Harmless CLI noise.** The Firebase CLI may print a `punycode` deprecation warning or ask about enabling extra features (for example Gemini) during setup. These come from the CLI, not from AngularFire, and are safe to ignore. |
8 | 10 |
|
9 | 11 | ### 1. Create a new project |
10 | 12 |
|
11 | 13 | ```bash |
12 | 14 | # Using yarn create |
13 | | -yarn create @angular <project-name> |
| 15 | +yarn create @angular@21 <project-name> |
14 | 16 | cd <project-name> |
15 | 17 | ``` |
16 | 18 | or |
17 | 19 |
|
18 | 20 | ```bash |
19 | 21 | # Using npm create |
20 | | -npm create @angular <project-name> |
| 22 | +npm create @angular@21 <project-name> |
21 | 23 | cd <project-name> |
22 | 24 | ``` |
23 | 25 |
|
24 | 26 | optionally installing the tooling directly: |
25 | 27 | ```bash |
26 | 28 | # Installing the tooling directly |
27 | | -npm install -g @angular/cli |
| 29 | +npm install -g @angular/cli@21 |
28 | 30 | ng new <project-name> |
29 | 31 | cd <project-name> |
30 | 32 | ``` |
31 | 33 |
|
32 | | -The Angular CLI's `new` command will set up the latest Angular build in a new project structure. |
| 34 | +These commands set up an Angular 21 project, the version AngularFire 21 supports. |
33 | 35 |
|
34 | 36 | ### 2. Install AngularFire and Firebase |
35 | 37 |
|
| 38 | +AngularFire 21 is currently a release candidate, published under the `next` tag: |
| 39 | + |
36 | 40 | ```bash |
37 | | -ng add @angular/fire |
| 41 | +ng add @angular/fire@next |
38 | 42 | ``` |
39 | 43 |
|
40 | 44 | This installs AngularFire and configures your project. `ng add` will: |
41 | 45 |
|
42 | 46 | 1. Prompt you to select the features to enable and the Firebase project to use, signing you in to Firebase if needed. |
43 | 47 | 2. Add `provideFirebaseApp(...)`, along with a provider for each feature you select, to your app configuration (for example `app.config.ts`), with your Firebase configuration inlined. No environment files are created. |
44 | 48 |
|
| 49 | +`ng add` writes the version it installed into your `package.json`, and today that is a canary release such as `21.0.0-rc.1-canary.95b3de1` rather than the release candidate. To replace it with the release candidate, `21.0.0-rc.1`, run: |
| 50 | + |
| 51 | +```bash |
| 52 | +npm install --save-exact @angular/fire@next |
| 53 | +``` |
| 54 | + |
45 | 55 | ### 3. Inject `Firestore` |
46 | 56 |
|
47 | 57 | Open `/src/app/app.ts` and make the following changes: |
|
0 commit comments