Fireship · @fireship
Puppeteer on Cloud Functions
Uploaded August 21, 2018 · Length 9:12
Summary
server-side rendering with puppeteer and cloud functions for firebase hosting
- server-side rendering
- puppeteer cloud functions
- firebase hosting
- cloud functions puppeteer
- server rendering
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:06
when cloud functions 2.0 came out last
- 0:09
month we got access to a whole bunch of
- 0:11
cool new features such as a node 8
- 0:13
runtime custom memory and region
- 0:15
settings and the ability to use
- 0:16
puppeteer in the cloud functions
- 0:18
environment today we're going to put all
- 0:20
these new features to use so we can
- 0:21
server-side render pretty much any
- 0:23
JavaScript application from a firebase
- 0:25
function if you're new the channel like
- 0:27
and subscribe and if you want to get
- 0:28
really good at cloud functions consider
- 0:30
becoming a pro member to get access to
- 0:32
the cloud functions master course so one
- 0:35
of the major benefits of the new node 8
- 0:37
runtime and cloud functions is that it
- 0:39
allows us to run puppeteer and headless
- 0:41
Chrome headless chrome is just a web
- 0:43
browser that can run on your server and
- 0:45
puppeteer is a high level API allowing
- 0:48
you to interact with the browser it's
- 0:50
very intuitive to use and you get direct
- 0:52
access to the Dom on the rendered page
- 0:54
so you can use it for things like web
- 0:56
scraping server-side rendering and to
- 0:58
end testing performance benchmarking and
- 1:00
probably a whole bunch of other things
- 1:02
as well
- 1:02
if we go back to episode 66 we used an
- 1:06
app called render Tron to server-side
- 1:08
render and angular application but one
- 1:10
of the major drawbacks that approach is
- 1:12
that we needed to build and maintain our
- 1:14
own docker container in this video we'll
- 1:16
build an app that's equivalent to render
- 1:17
Tron but on a firebase cloud function
- 1:20
I'm going to be building this function
- 1:21
in an ionic 4 project but you can build
- 1:24
it by itself or with any other
- 1:25
JavaScript framework the cloud functions
- 1:28
back end is completely agnostic to your
- 1:30
front-end if you're in a brand-new
- 1:32
project run firebase and it functions
- 1:34
and then I've selected the typescript
- 1:36
option and it's very important that
- 1:38
you're up to date on the latest version
- 1:40
of firebase tools because all this stuff
- 1:42
is very new from there we'll see the end
- 1:44
of the functions directory and then
- 1:46
we'll need to set up node.js version 8
- 1:48
as the runtime open the package JSON
- 1:51
create an object called engines then set
- 1:54
node to a string value of eight then
- 1:57
another thing you want to do if you're
- 1:58
using typescript is add the Dom Lib to


