< Back

Here’s What Your Web App Can Do Today

A comprehensive list for developers who have no idea

calendar

Oct 9, 2024

Header for posting Here’s What Your Web App Can Do Today
Photo by Onur Binay on Unsplash

Are you a developer who believes that web apps are inferior to native apps? Do you think that web apps can’t do all the things native apps can?

Well, I don’t blame you.

Many web apps are just dumbed-down versions of their native counterparts that only seem to exist to get you to install the native version. These web apps are either deliberately dumbed down or their developers really have no clue what web apps can do. And that’s a shame because web apps can do much more than you probably think.

Five years ago, I created What PWA Can Do Today, a collection of demos of what is possible with PWAs (progressive web apps) today. I can’t even count the times developers reached out to me to say they had no idea that web apps could do all these things.

Most just assumed web apps weren’t capable because of all these big brands telling them to install the native app “to get the full experience” (which is usually a lie)

While web apps are not perfect, you’ll be surprised at what they’re capable of. Here’s a list of what your web app can do today.

Work offline

Your web app can work perfectly fine without a network. Most web apps treat offline as an error and leave it up to the browser to show a useless white screen with a dinosaur. But offline is a common state that your web app can be in and that it should be able to handle.

Your users are often in places with a bad network or no network at all (parking garage, remote area, etc.) and in those situations, your web app should provide the best possible user experience.

You can make your web app work offline by implementing a Service Worker. This is a special kind of web worker that can intercept network traffic and cache assets and responses to routes locally. When the app is offline, the Service Worker can serve responses from the cache.

It can also store requests while your app is offline and retry them when the network is back.

Here’s a basic Service Worker that takes care of this for you:

A basic Service Worker to make your web app work offline - DannyMoerkerke/basic-service-worker

Support: all browsers and platforms

Service Worker API on MDN

Detect offline

An important feature to implement offline support is the ability to detect when the network is gone and that is what your web app can do with the online and offline events.

You can for example use the offline event to show a notification to the user that the network is gone and the online event to retry any requests that were saved while the app was offline.

Support: all browsers and platforms

navigator.onLine and online/offline events on MDN

Install to Home Screen

Just like a native app, a web app can be installed to the Home Screen of your phone, tablet, or laptop/desktop PC. In the manifest.json file, you can specify the name and icons to be used for the Home Screen, and in supporting browsers, you can even add a description and some screenshots of your app that will be shown when the user clicks a button to install it.

This brings the installation process closer to that of native apps and helps to familiarise users with installable web apps.

Web app install bottom sheet in Chrome on Android
Web app install UI in Chrome on macOS

Support: all browsers and platforms, on iOS there is no native install UI with screenshots and installing the app is done through the share menu.

Install prompt on web.dev
Richer install UI on web.dev

Receive push notifications

Your web app can receive push notifications, even when it’s not running. This is a very important feature to engage users of your web app because notifications enable you to reach them even when they’re not using your web app.

The Service Worker takes care of receiving and showing the notifications. When the web app is not running, the OS will take care of activating the Service Worker and then dispatch a push event that you can set an event handler for to show the notification to the user.

Support: all browsers and platforms, on iOS the web app needs to be added to the Home Screen

Demo
Push API on MDN

Access geolocation data

Has this ever happened to you? You’re somewhere in a city and you’re trying to find a certain shop close to you. You go to that shop's website and to find the nearest location, they ask you for the zip code of the location you’re at now.

I don’t know about you, but when I’m somewhere in a city I usually don’t know the zip code of wherever I am at that moment. Instead, they could have prompted you for permission to access your GPS location so they could show you the exact directions to that store.

Web apps have had access to geolocation data for many years now and you can get the user’s location with just a few lines of code using the navigator.geoLocation object.

Support: all browsers and platforms

Demo
Geolocation API on MDN

Access camera and microphone

Web apps can access the microphone and camera of any device, both on mobile and desktop. When the user has multiple devices connected, web apps can show a list so the user can pick one. On mobile devices, both the front and back cameras can be used.

The resulting video stream from the camera can be shown in picture-in-picture mode.

Support: all browsers and platforms

Demo
MediaDevices.getUserMedia() on MDN

Record audio and video

When a web app accesses the camera or microphone of the user’s device, the video and audio coming from these devices are exposed as a stream that can be recorded using the MediaRecorder object. The resulting data can be saved as a file or played as audio or video.

Support: all browsers and platforms

Demo
MediaRecorder on MDN

Access the file system

On desktop, web apps are now able to access the native file system which enables them to create files and folders and store these on disk as well as editing and saving existing files. This means that apps that edit text files and photos for example can now be implemented as web apps.

On mobile devices, the Origin Private File System (OPFS) is available, which is a virtual file system optimized for very fast reading and writing. Although the files and folders in it don’t necessarily correspond to actual files and folders on disk, it looks like a real file system from the perspective of the web app.

You can create files and folders on it, read and save files, and enumerate its contents just like with the native file system.

Support: in Chrome and Edge on desktop the File System API and Origin Private File System are available, on Android, Safari on macOS and iOS the Origin Private File System is available

Demo
File System API on MDN

Log in with face or fingerprint

Web apps can let users log in using biometrics like face recognition and fingerprint or an external USB key. This means your web app can get rid of passwords and use FaceID, TouchID, Windows Hello, and Android fingerprint recognition to authenticate users.

This can not only drastically improve the security of your web app, but also the user experience since it can autofill these biometric credentials so your users can simply log in by showing their face or touching the fingerprint sensor.

If you don’t want to get rid of passwords entirely in your web app, you can also use this as two-factor authentication (2FA) for added security.

Support: all browsers and platforms

Demo
Web Autentication API on MDN

Detect faces and barcodes

Until recently, barcode and face detection could only be done using a (heavy) JavaScript library but now this is also natively possible in most browsers.

Browsers can detect a large variety of barcode formats which enables the development of interesting apps, for example, apps for retail companies that work with different barcodes.

Face detection is currently possible with the Shape Detection API, although this is limited to just detecting faces, not recognizing them.

Support: barcode detection is supported in Edge on macOS, Chrome on ChromeOS and macOS, and Chrome on Android. Both barcode and face detection are supported in Safari on macOS and iOS but needs to be enabled with a flag.

Demo barcode detection
Demo face detection
BarcodeDetector on MDN
Shape Detection API on Chrome Developers

Record the screen

On desktop, web apps can record browser tabs, applications, or full screens. Just like with webcams and microphones, the resulting video is exposed as a video stream that can be saved to a file or manipulated.

Chrome and Edge also implemented some experimental functionality that enables web apps to control a captured browser tab by sending arbitrary commands and scrolling the page that is recorded or by limiting the recording to certain DOM elements on the recorded page.

Support: all browsers on desktop

Demo
MediaDevices.getDisplayMedia() on MDN

Download files in the background

A great use case for downloading files in the background is a podcast app. If you want to download a new episode of your favorite podcast you need to keep the web app open, otherwise the partially downloaded file will be lost. When you’re downloading a large file or you’re downloading on a slow network this can take a long time and be very annoying.

The Background Fetch API enables web apps to initiate these downloads and then offload the process to the Service Worker. If the user then closes the app, the Service Worker will continue to download the file in the background. This means you no longer need to wait for the download to finish before you can close the app.

Support: Chrome and Edge on desktop and Android, upcoming support in Safari Tech Preview

Demo
Background Fetch API on MDN

Background Fetch API demo on Android

Show controls on the lock screen

The Media Session API enables web apps to display controls and metadata on the lock screen of a phone or tablet when the web app is playing audio or video.

For example, a music player web app can display album art and control buttons when music is playing, just like the native apps for Spotify and Apple Music do.

You can combine this feature with access to the file system and downloading files in the background to build a full-fledged music player web app.

Lock screen controls for a web app on iOS

Support: all browsers and platforms except FireFox on Android

Demo
Media Session API on MDN

Handle payments

If your web app sells products, you can use the Payment Request API to let users pay with a credit card, Apple Pay, or Google Pay. The API aims to make payments on the web simpler by reducing the steps that are needed to make an online payment and possibly eliminate checkout forms altogether.

Support: Chrome and Edge support Google Pay, Safari supports Apple Pay

Demo
Payment Request API on MDN

Access sensors

Through the DeviceMotionEvent and DeviceOrientationEvent, web apps can detect the physical orientation of a mobile device and the speed of changes for the device’s position and orientation.

Web apps can use this to change their behavior based on the orientation of the device or when users move their device, for example, to detect certain gestures or move a 3D model when the device moves.

The information these events provide comes from accelerometer, gyroscope, and gravity sensor that most mobile devices are equipped with. In Chrome and Edge, web apps can also use the Generic Sensor API to get more detailed information from these sensors and access them separately from the DOM. This Generic Sensor API can easily be extended and now also provides experimental access to the ambient light sensor and magnetometer in Chrome.

Support: DeviceMotionEvent and DeviceOrientationEvent are supported in all browsers on all platforms, Generic Sensor API is supported in Chrome and Edge

Demo device orientation
Demo device motion
Device orientation event on MDN

Detect page visibility and device orientation

Being able to detect the current orientation of a device and whether or not a page is visible to the user are very useful features for web apps. For example, certain tasks can be paused when an app is moved to the background (like animations or media playback) to save battery and a change in orientation can be used to adapt the user interface.

Web apps can use the Screen Orientation API and the PageVisibility API to detect this.

Support: all browsers and platforms

Demo Page Visibility API
Demo Screen Orientation API
Page Visibility API on MDN
Screen Orientation API on MDN

Create peer-to-peer connections

Using WebRTC, web apps can set up secure and reliable peer-to-peer connections for transferring data and media. This way, users can chat, video-chat, and transfer files to each other without needing to use a server in the middle.

A server is only needed to allow users to discover each other for setting up the initial connection and after that, they have a direct connection. WebRTC is also used by apps like WhatsApp.

Support: all browsers and platforms

Demo
WebRTC API on MDN

Provide smooth page transitions

Since the rise of single-page apps, web apps have tried to emulate smooth page transitions like these are common in native apps. While possible, this is very error-prone and places quite some restrictions on the architecture of the app. For example, these types of animations are not possible for multi-page apps.

The View Transitions API is one of the most useful features that has been added to the web platform in recent years. It enables web apps to have smooth and compelling page transitions using only CSS animations and a minimum amount of JavaScript.

In Chrome, Edge, and Safari Tech Preview, these view transitions can now also be used in multi-page apps, which means that web apps can create page transitions between completely separate HTML pages.

Since view transitions are transitions between DOM states and not necessarily pages, these can be used for all types of changes in an HTML page. For example, if a row needs to be moved from one <table> to another, the app can simply move it using JavaScript and the browser will take care of animating the change in position.

This makes it very easy to add compelling and useful animations without complex code.

Support: Chrome, Edge and Safari on all platforms, cross-document view transitions in Chrome, Edge and Safari Tech Preview

Demo
View Transition API on MDN

View transitions demo on Android

Access contacts

Web apps can access the contacts list on phones and tablets, which is really useful for communication apps. All data that you have saved in your contacts, like phone number, email, address, etc, is available to web apps.

Support: Chrome, Edge and Safari on mobile, in Safari a flag needs to be enabled

Demo
Contact Picker API on MDN

What can your web app do?

I hope this list has convinced you of the power of web apps and has inspired you to build some useful features for your own web app.

Maybe you’ve learned about some features that you didn’t know about before but that you can use now to make your app even better. If so, I’d love to hear about it!


Join my email list Modern Web Weekly, for a weekly update on Progressive Web Apps (PWA), Web Components and new features of the modern web platform, tested and explained in plain English.