Fireship · @fireship
Angular Universal on Cloud Functions or AppEngine
Uploaded January 23, 2019 · Length 11:29
Summary
Learn how to server-side render an Angular app and deploy it to Google App Engine or Firebase Cloud Functions.
- angular universal
- server-side rendering
- angular deployment
- google app engine
- firebase cloud functions
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
one of the biggest challenges with
- 0:08
building a single page application is
- 0:10
making the app visible to search engines
- 0:11
and Link BOTS
- 0:12
fortunately with angular Universal we
- 0:14
have a reliable package for rendering
- 0:16
our apps on the server not only does
- 0:18
this provide SEO but it can also improve
- 0:20
the initial page load speed in today's
- 0:22
video you'll learn how to server-side
- 0:23
render an angular app then deploy it to
- 0:25
Google App Engine or firebase cloud
- 0:27
functions if you're new here like and
- 0:29
subscribe and make sure to follow along
- 0:31
with the full source code on fire ship
- 0:32
io let's start by talking about what
- 0:34
server-side rendering is and when you
- 0:36
would want to use it in any normal
- 0:38
JavaScript app whether it be angular
- 0:39
view or react you will provide the
- 0:41
browser with a JavaScript bundle then
- 0:43
the browser will parse that bundle of
- 0:44
JavaScript and figure out how to render
- 0:46
the HTML that's a great way to build a
- 0:48
modern web app because it will make the
- 0:50
user experience feel very fast and
- 0:51
responsive like a native app but the
- 0:53
problem is that a lot of bots out there
- 0:55
don't execute JavaScript so that means
- 0:57
if somebody shares a deep link in your
- 0:59
app and that link renders some kind of
- 1:01
dynamic content the only thing the bot
- 1:03
will see is your initial index.html file
- 1:05
so the purpose of angular Universal and
- 1:07
server-side rendering is to offload some
- 1:09
of this work to the server so when the
- 1:12
user first visits a deep link they'll
- 1:13
get some rendered HTML with the dynamic
- 1:15
content already included for example the
- 1:18
Twitter bot just wants to read the meta
- 1:19
tags and ahead of the document so it's
- 1:21
just going to grab that HTML and then
- 1:23
not worry about executing any JavaScript
- 1:25
on the page when you have just a regular
- 1:27
user they'll get that same pre-rendered
- 1:28
HTML so this usually results in a faster
- 1:30
initial page load then angular's
- 1:32
JavaScript will take over so it'll
- 1:34
behave just like a regular angular app
- 1:36
on subsequent navigations in order to
- 1:38
make this possible we can't really use
- 1:40
firebase hosting directly because it's
- 1:42
just a static host we need an actual
- 1:44
node.js server to dynamically render the
- 1:46
content when a page is requested we have
- 1:48
two good deployment options for a
- 1:50
firebase project Google App Engine and
- 1:52
firebase cloud functions there are some
- 1:54
trade-offs between the two but I'll show
- 1:55
you how to set up both of them in this
- 1:56
video and they can both be used on the
- 1:58
free tier I'm starting out from a brand


