You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-7
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
-**Observable based** - Use the power of RxJS, Angular, and Firebase.
11
11
-**Realtime bindings** - Synchronize data in realtime.
12
-
-**Authentication** - Log users in with a variety of providers and monitor authentication state in realtime.
12
+
-**Authentication** - Log users in with a variety of providers and monitor authentication state.
13
13
-**Offline Data** - Store data offline automatically with AngularFirestore.
14
14
-**Server-side Render** - Generate static HTML to boost perceived performance or create static sites.
15
15
-**ngrx friendly** - Integrate with ngrx using AngularFire's action based APIs.
@@ -25,7 +25,7 @@
25
25
26
26
[Upgrading to v5.0? Check out our guide.](docs/version-5-upgrade.md)
27
27
28
-
**Having troubles?** Get help on the [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk) (offically supported), the [Firebase Community Slack](https://firebase.community/) (look for the `#angularfire2` room), [Gitter](https://gitter.im/angular/angularfire2), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2).
28
+
**Having troubles?** Get help on the [Firebase Mailing List](https://groups.google.com/forum/#!forum/firebase-talk) (officially supported), the [Firebase Community Slack](https://firebase.community/) (look for the `#angularfire2` room), [Gitter](https://gitter.im/angular/angularfire2), or [Stack Overflow](https://stackoverflow.com/questions/tagged/angularfire2).
29
29
30
30
## Install
31
31
@@ -92,17 +92,25 @@ Firebase offers two cloud-based, client-accessible database solutions that suppo
92
92
### Upload files
93
93
-[Getting started with Cloud Storage](docs/storage/storage.md)
94
94
95
-
### Universal
96
-
-[Server-side Rendering with Universal](docs/server-side-rendering.md)
97
-
98
95
### Send push notifications
99
96
-[Getting started with Firebase Messaging](docs/messaging/messaging.md)
100
97
101
98
### Directly call Cloud Functions
102
99
-[Getting started with Callable Functions](docs/functions/functions.md)
103
100
104
-
### Deploy to Firebase Hosting
105
-
-[Deploying AngularFire to Firebase Hosting](docs/deploying-angularfire-to-firebase.md)
101
+
### Deploying your application
102
+
103
+
> Firebase Hosting is production-grade web content hosting for developers. With Hosting, you can quickly and easily deploy web apps and static content to a global content delivery network (CDN) with a single command.
104
+
105
+
-[Deploy your Angular application on Firebase Hosting](docs/deploying-angularfire-to-firebase.md)
106
+
107
+
#### Server-side rendering
108
+
109
+
> Angular Universal is a technology that allows you to run your Angular application on a server. This allows you to generate your HTML in a process called server-side rendering (SSR). Angularfire is compatible with server-side rendering; allowing you to take advantage of the Search Engine Optimization, link previews, the performance gains granted by the technology, and more. [Learn more about Angular Universal](https://angular.io/guide/universal).
110
+
111
+
-[Getting started with Angular Universal](docs/universal/getting-started.md)
112
+
-[Deploying your Universal application on Cloud Functions for Firebase](docs/universal/cloud-functions.md)
113
+
-[Prerendering your Universal application](docs/universal/prerendering.md)
# Deploying your Universal application on Cloud Functions for Firebase
2
+
3
+
After [setting up your application with Angular Universal as outlined in Getting Started](getting-started.md), you're now ready to build your application for Firebase Hosting & Cloud Functions.
4
+
5
+
> Cloud Functions for Firebase lets you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers. [Learn more about Cloud Functions for Firebase](https://firebase.google.com/docs/functions/).
6
+
7
+
If you don't already have the Firebase CLI installed, do so:
8
+
9
+
```bash
10
+
npm i -g @firebase-tools
11
+
firebase login
12
+
```
13
+
14
+
Then inside your project root, setup your Firebase CLI project:
15
+
16
+
```bash
17
+
firebase init
18
+
```
19
+
20
+
Configure whichever features you'd want to manage but make sure to select at least `functions` and `hosting`. Choose Typescript for Cloud Functions and use the default `public` directory for Hosting.
21
+
22
+
After you're configured, you should now see a `firebase.json` file in your project root. Let's add the following `rewrites` directive to it:
23
+
24
+
```js
25
+
{
26
+
// ...
27
+
"hosting": {
28
+
// ...
29
+
"rewrites": [
30
+
{ "source":"**", "function":"universal" }
31
+
]
32
+
}
33
+
}
34
+
```
35
+
36
+
This will inform Firebase Hosting that it should proxy all requests to Cloud Functions, if a file isn't already present in the hosting directory.
37
+
38
+
Let's go ahead and modify your `package.json` to build for Cloud Functions:
39
+
40
+
```js
41
+
"scripts": {
42
+
// ... omitted
43
+
"build":"ng build && npm run copy:hosting && npm run build:ssr && npm run build:functions",
Server-side rendering (SSR) is the process of converting a JavaScript app to plain HTML at request-time, allowing search engine crawlers and linkbots to understand page content reliably.
4
4
5
5
## 0. Prerequisites
6
6
7
7
-@angular/cli >= v6.0
8
-
-angularfire2 >= v5.0.0-rc.7
8
+
-@angular/fire >= v5.0.0
9
9
10
10
## 1. Generate the Angular Universal Server Module
11
11
@@ -19,8 +19,8 @@ ng generate universal --client-project <your-project>
19
19
20
20
[ExpressJS](https://expressjs.com/) is a lightweight web framework that can serve http requests in Node. First, install the dev dependencies:
Test your app locally by running `npm run build:ssr && npm run serve:ssr`.
141
-
142
-
## 5.0 Deployment
143
-
144
-
With an existing Firebase project, you can easily deploy your ExpressJS server to [App Engine Flex](https://cloud.google.com/appengine/docs/flexible/) (Note: This is a paid service based on resource allocation).
145
-
146
-
147
-
1. Install [gcloud CLI tools](https://cloud.google.com/sdk/gcloud/) and authenticate.
148
-
2. Change the start script in package.json to `"start": "npm run serve:ssr"`
149
-
2. Run `gcloud app deploy` and you're on the cloud.
150
-
151
-
## Additional Resources
151
+
Test your app locally by running `npm run build && npm run serve:ssr`.
0 commit comments