Progressive Web Apps (PWA) provide an installable, app-like experience on desktop and mobile that is built and delivered directly via the web. They're website applications that are sharp, reliable, and efficient. PWAs can run in a browser tab, but are also installable. Bookmarking a page has traditionally been the only way to home screen a website. Installable web apps are a move away from the dependency of the proprietary app marketplace ecosystem.
Before we dive into how to build one, let's explore why PWAs are popular:
To build a PWA, you need to implement the following core components:
{
"name": "My Cool App",
"short_name": "Cool App",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#000000",
"icons": [
{
"src": "icons/cool-app-192.png",
"sizes": "192x192"
},
{
"src": "icons/cool-app-512.png",
"sizes": "512x512"
}
]
}
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open('my-cache').then(function(cache) {
return cache.addAll([
'/',
'/index.html',
'/styles/main.css',
'/scripts/main.js',
'/images/my-logo.png',
]);
})
);
});
self.addEventListener('fetch', function(event) {
event.respondWith(
caches.match(event.request).then(function(response) {
return response || fetch(event.request);
})
);
});
You can validate your PWA using Lighthouse, an open-source, automated tool for improving the quality of web pages. It checks the performance, accessibility, and progressive web app scores of a web page.
PWAs have a direct impact on businesses through engaging user experiences that lead to higher conversions. They provide benefits of a native app but via a web platform, including the ability to work offline and push notifications, and thereby can fill a gap in your mobile strategy.
You may also use new frameworks such as Workbox to automate the generation of service workers and app shell. It's a robust tool that enables customizable strategies for dealing with offline scenarios. By making PWAs part of your web product strategy, you can reach users right where they are – on the web, without the need to go to an app store.
1. Do PWAs require a lot of storage space?
No, PWAs often take up less space than traditional native apps. They also allow for dynamic content caching, which means they use storage space more efficiently.
2. Can PWAs work offline?
Yes, this is one of the defining features of PWAs. With the help of service workers, PWAs can cache and serve files, enabling functionality-offline.
3. Are PWAs secure?
Yes, PWAs must be served over HTTPS. This ensures that the app cannot be tampered with or intercepted by an attacker.
4. Do PWAs have access to device features?
Yes, PWAs have access to a device's capabilities via APIs. This includes features like geolocation, camera functionality, and even push notifications.
5. Can I use my existing website and transform it into PWA?
Yes, you can turn an existing website into a PWA. The website needs a service worker to be set up and registered and a manifest file.