Protocol Handlers

Progressive Web Apps (PWAs) have the ability to handle web protocols, which means they can respond to specific URL schemes. For example, a PWA can register to handle mailto: links, so that clicking on an email link can open a compose window in the PWA instead of opening the default mail client.

With protocol handlers, your PWA can provide a more integrated user experience, functioning more like a native application by becoming the default handler for specific protocols on the user's device.

Overview

Protocol handlers allow your PWA to:

  • Handle standard protocols: mailto, tel, sms, etc.

  • Register custom protocols: Using the web+ prefix

  • Intercept protocol links: Capture clicks on protocol URLs

  • Provide integrated experiences: Open your PWA instead of native apps

  • Deepen user engagement: Make your PWA the default handler

Real-world examples:

  • Email clients handling mailto: links

  • Messaging apps handling sms: or tel: links

  • Music apps handling web+music: links

  • Recipe apps handling web+recipe: links

  • Game launchers handling web+game: links

Browser Support

Browser
Support
Notes

Chrome (Desktop)

✅ Full

Since Chrome 96

Chrome (Android)

✅ Full

Since Chrome 96

Edge (Desktop)

✅ Full

Since Edge 96

Safari

❌ Not supported

-

Firefox

❌ Not supported

-

circle-exclamation

Configuration

Basic Configuration

Complete Example

Protocol Parameter

The protocol parameter specifies the protocol scheme your PWA can handle. It must follow these rules:

Standard Protocols

Standard web protocols can be registered without any prefix:

mailto - Email addresses

Usage: <a href="mailto:[email protected]">Email Me</a>

tel - Telephone numbers

Usage: <a href="tel:+1234567890">Call Us</a>

sms - SMS messages

Usage: <a href="sms:+1234567890">Text Us</a>

Custom Protocols

Custom protocols must start with the web+ prefix:

Valid custom protocols:

Invalid custom protocols:

circle-exclamation

URL Parameter

The url parameter defines where to redirect when the protocol is triggered. The URL can include a placeholder %s that will be replaced with the protocol's argument.

Simple String Format

How it works:

Advanced Object Format

Just like with shortcuts and start_url, you can use the full URL object configuration:

Corresponding Symfony route:

Path Type Reference

The path_type_reference option controls URL generation:

Value
Type
Example Output

0

Absolute URL

https://app.com/foo/bar

1

Absolute path (default)

/foo/bar

2

Relative path

../bar

3

Network path

//app.com/foo/bar

Example:

Placeholder Parameter

When you need more control over the placeholder format, you can use the placeholder parameter. The bundle will automatically format it as placeholder=%s:

How it works:

  • User clicks: web+jngl:example

  • PWA opens: /handle?type=example

Without placeholder (default):

  • User clicks: web+jngl:example

  • PWA opens: /handle?example (not ideal)

This allows you to create more semantic URL patterns for your protocol handlers.

Use Cases

1. Email Client

Handle mailto: links to compose emails in your PWA:

2. Phone Dialer

Handle tel: links for a calling app:

3. Recipe App

Handle custom web+recipe: protocol:

Sharing recipes:

4. Music Player

Handle web+music: protocol for streaming:

5. Multi-Protocol App

Support multiple protocols in one PWA:

Registration Process

1. User Installs PWA

When a user installs your PWA, the browser detects protocol handlers in the manifest.

2. Permission Request

The browser prompts the user to allow the PWA to handle specified protocols.

Chrome prompt example:

3. Default Handler

If the user allows, your PWA becomes an available handler for those protocols.

User can:

  • Set your PWA as the default handler

  • Choose on a case-by-case basis

  • Revoke permissions later

Testing

Create test HTML page with protocol links:

2. Check Manifest in DevTools

3. Test Registration Flow

4. JavaScript Testing

User Management

Checking Permissions

Users can manage protocol handlers in browser settings:

Chrome:

Edge:

Revoking Permission

Users can remove your PWA as a protocol handler:

  1. Open browser settings

  2. Go to Protocol handlers / Default apps

  3. Find your PWA

  4. Click "Remove" or "Block"

Best Practices

1. Request Only Needed Protocols

2. Provide Clear Value

Explain why users should allow protocol handling:

3. Handle Missing Parameters

4. Sanitize Protocol Input

5. Provide Fallback

Always ensure your app works even if protocol handlers aren't available:

6. Test Across Browsers

Security Considerations

1. HTTPS Required

Protocol handlers only work over HTTPS:

2. Validate Input

Always validate and sanitize protocol arguments:

3. Prevent Open Redirects

4. Respect User Choice

Always provide an easy way for users to opt-out:

Common Issues

Protocol Handler Not Appearing

Problem: PWA doesn't appear as protocol handler option

Solutions:

  • Verify PWA is installed (not just bookmarked)

  • Check browser supports protocol handlers (Chrome/Edge only)

  • Ensure manifest includes protocol_handlers

  • Clear browser cache and reinstall PWA

  • Check DevTools → Application → Manifest

Permission Not Requested

Problem: Browser doesn't prompt for protocol handler permission

Solutions:

  • User must click a protocol link first

  • Browser only prompts once per protocol

  • Check if permission was previously denied

  • Reset permissions in browser settings

Wrong URL Generated

Problem: Protocol handler opens wrong URL

Solutions:

  • Verify %s placeholder is in URL

  • Check path_type_reference value

  • Ensure Symfony route exists

  • Check route parameters match configuration

Protocol Not Working

Problem: Clicking protocol link doesn't open PWA

Solutions:

  • Verify protocol format (must start with web+ for custom)

  • Check PWA is set as default handler

  • Test in supported browser (Chrome/Edge)

  • Verify PWA is still installed

Troubleshooting

Debug Protocol Handling

Check Protocol Registration

Test Without Installation

Protocol handlers only work for installed PWAs. To test:

  1. Install PWA first

  2. Then click protocol links

  3. Or test from external page/app

Resources

  • MDN Protocol Handlers: https://developer.mozilla.org/en-US/docs/Web/Manifest/protocol_handlers

  • Web.dev: https://web.dev/url-protocol-handler/

  • Chrome Platform Status: https://chromestatus.com/feature/5680742077038592

  • W3C Spec: https://w3c.github.io/manifest-app-info/#protocol_handlers-member

Last updated

Was this helpful?