Protocol Handlers
Learn how PWAs can register themselves as handlers for specific URL schemes.
What's a Protocol exactly?
A protocol (also known as a URL scheme) is the first part of a URL. The most common examples are http: and https: which are used for web pages. You might also recognize mailto: which opens your email client when followed by an email address, or tel: which precedes a phone number and typically prompts a call.
Protocol handlers in PWAs
As it turns out, PWAs can register themselves as protocol handlers. When a user opens a URL that begins with one of the protocols you’ve registered, your PWA can appear as an available option to handle it. There are two ways to do this:
- Use navigator.registerProtocolHandler() in your client-side JavaScript code
- Set the protocol_handlers property in your app manifest
In both scenarios, the handler URL must contain the placeholder %s. At runtime, this placeholder is replaced with the actual URL passed to your application.
Code
Ready to generate your PWA?
Try our PWA toolkit free of charge and without limits for 14 days. No credit card required.
Generate PWA See plans