Fireship · @fireship
Progressive Web Apps in 100 Seconds // Build a PWA from Scratch
Uploaded December 16, 2020 · Length 8:10
Summary
Build a progressive web app (PWA) from scratch using Chrome Lighthouse, service workers, and Workbox, covering offline mode, push notifications, and caching.
- progressive web apps
- pwa from scratch
- chrome lighthouse
- service workers
- workbox
- offline mode
- push notifications
- caching
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
[Music]
- 0:00
progressive web apps build websites that
- 0:02
deliver an experience indistinguishable
- 0:05
from native mobile apps when smartphones
- 0:07
first hit the scene back in 2008 they
- 0:09
brought with them all kinds of new
- 0:10
features that weren't available on the
- 0:12
web like offline mode push notifications
- 0:14
cameras geolocation and more internet
- 0:16
explorer powered the web back then and
- 0:18
web developers had no way to access most
- 0:20
in-device features in the 2020s though
- 0:22
the game has changed the web platform
- 0:24
has reached near feature parity with
- 0:26
native apps notice how the twitter pwa
- 0:28
can be installed just like a native app
- 0:30
it works without a connection it can
- 0:31
interact with the device camera and
- 0:33
receive push notifications and on top of
- 0:35
that the web offers much better
- 0:36
distribution than app stores and doesn't
- 0:38
take a 30 cut of your revenue not to
- 0:40
mention your app will work on ios
- 0:42
android and the web from a single code
- 0:44
base if you own a website turning it
- 0:46
into a progressive web app is easier
- 0:48
than you might think first open up the
- 0:50
lighthouse tool in chrome dev tools to
- 0:52
run an audit on your site it'll tell you
- 0:54
how well your site performs and what
- 0:55
needs to change to qualify as a pwa at a
- 0:58
bare minimum the site needs to load
- 1:00
quickly and be accessible on mobile most
- 1:02
sites already check this box the more
- 1:03
difficult requirement is making the app
- 1:05
work offline normally a website runs on
- 1:08
a single thread while the tab is open
- 1:09
however modern websites can now register
- 1:12
a service worker which is just a script
- 1:14
that runs in the background it can
- 1:15
perform caching background sync and
- 1:18
listen to push notifications among other
- 1:20
things the implementation is actually
- 1:22
very simple we just check if the browser
- 1:23
supports this feature then register a
- 1:25
javascript file as the worker once
- 1:27
registered you'll find it activated in
- 1:29
the application tab in chrome devtools
- 1:31
from there you can write your own code
- 1:33
in the worker file or use a library like
- 1:35
workbox to do everything for you most
- 1:36
importantly you'll want to cache the
- 1:38
urls in your app so they can be viewed
- 1:40
offline you can inspect the cache and
- 1:42
other background services here in the
- 1:43
application tab the final step is to
- 1:45
create a manifest.json file which
- 1:48
contains icons and other metadata about
- 1:50
the app once the requirements have been
- 1:51
met you'll unlock the pwa achievement
- 1:54
and lighthouse at which point your app
- 1:56
can be installed on most native devices
- 1:58
and can even be listed on google play or


