On this page
A PWA protocol handler URL not working can fail at several points: the app may not be registered, the user may have declined a prompt, or the handler page may reject the incoming URL. Test each boundary separately before release, and provide a way to open the same workflow without a protocol handler.
This guide uses a fictional web+tasks: scheme and synthetic task names. It includes an application-level test page you can adapt to an existing PWA.
Key Takeaways
- A protocol handler associates a supported scheme with a web URL template. The browser substitutes the incoming URL for
%swhen launching the handler. - Registration and launching depend on the browser, operating system, installation state, and user choices. A working handler page alone does not prove registration works.
- Treat the incoming URL as untrusted input. Validate it before performing any action.
- Offer a normal HTTPS entry point where users can paste a synthetic or non-sensitive protocol URL if launching fails.
- Current W3C and browser documentation could not be consulted for this article. Verify the target browsers’ current requirements and support before publication and release.
How the mapping works
A web app manifest can declare a protocol handler using a scheme and a URL template. For example, the following is an excerpt to merge into the manifest of an existing installable PWA whose scope includes /app/:
{
"protocol_handlers": [
{
"protocol": "web+tasks",
"url": "/app/open/?target=%s"
}
]
}
Conceptually, a supported launch of web+tasks:review opens the handler page with the incoming URL substituted into target. The substitution is URL-encoded for use in the template; the page can recover the parameter with URLSearchParams. Do not decode the entire query string manually: query parsing handles the outer encoding, while any encoding inside the protocol URL belongs to the application's own validation rules.
This manifest excerpt is not a complete PWA configuration. Its /app/open/ route must serve your application, and the handler URL must meet the applicable manifest and scope rules. Confirm the current W3C specification and each target browser's official documentation for scheme restrictions, template processing, scope, and registration behavior; those sources were not available to check here.
Advertisement
Build a safe handler and fallback page
The following illustrative page serves two purposes: it processes a target parameter delivered to /app/open/, and it lets a user paste a URL manually at the same HTTPS route. It accepts only task identifiers made of letters, digits, and hyphens. Replace the final status message with your own authorized workflow after validation.
Serve it at /app/open/ as part of your existing app. It requires a browser with the URL and URLSearchParams APIs. The example was reviewed but not executed in this environment.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Open a task URL</title>
</head>
<body>
<h1>Open a task URL</h1>
<p>If your protocol link did not open the app, paste its URL below.</p>
<form id="open-form">
<label for="task-url">Task URL</label>
<input id="task-url" name="task-url" type="text" required>
<button type="submit">Check URL</button>
</form>
<p id="status" role="status" aria-live="polite"></p>
<script>
const form = document.getElementById('open-form');
const input = document.getElementById('task-url');
const status = document.getElementById('status');
function checkTaskUrl(raw) {
// This application does not accept query strings or fragments.
if (raw.includes('?') || raw.includes('#')) {
throw new Error('Query strings and fragments are not supported.');
}
let url;
try {
url = new URL(raw);
} catch {
throw new Error('Enter a valid URL.');
}
if (url.protocol !== 'web+tasks:' || url.host) {
throw new Error('Enter a web+tasks URL without a host.');
}
let taskId;
try {
taskId = decodeURIComponent(url.pathname);
} catch {
throw new Error('The task identifier has invalid encoding.');
}
if (!/^[a-z0-9-]{1,40}$/i.test(taskId)) {
throw new Error('The task identifier is not supported.');
}
return taskId;
}
function showResult(raw) {
try {
const taskId = checkTaskUrl(raw.trim());
status.textContent = 'Accepted task identifier: ' + taskId;
} catch (error) {
status.textContent = error.message;
}
}
form.addEventListener('submit', (event) => {
event.preventDefault();
showResult(input.value);
});
const targets = new URL(window.location.href).searchParams.getAll('target');
if (targets.length === 1) {
input.value = targets[0];
showResult(targets[0]);
} else if (targets.length > 1) {
status.textContent = 'Provide only one target parameter.';
}
</script>
</body>
</html>
The page does not navigate to the supplied URL or perform a task. It uses textContent rather than inserting input as HTML. A real application must also authorize access to the requested task on the server; a syntactically valid identifier is not proof of permission.
Keep the fallback reachable through an ordinary HTTPS link in your app or help documentation. If your deployment sends /app/open/ to a client-side router, check the server configuration so a direct request to that route also loads the page.
Release test plan
Use a staging deployment and fictional data. Record the browser and operating system versions, installation state, prompts, and results for each supported combination. The following checks distinguish application validation from operating-system or browser registration.
1. Check the fallback and validation first
Open /app/open/ directly over HTTPS. Enter each value in the form and confirm that the page reports the intended result:
| Input | Intended application result |
|---|---|
web+tasks:review | Accept task identifier review. |
web+tasks:review%2Dlater | Accept task identifier review-later after decoding the identifier. |
web+tasks:%ZZ | Reject invalid percent encoding. A URL parser may accept this text, so the application checks decoding explicitly. |
not a URL | Reject it as an invalid URL. |
https://example.test/ | Reject the unsupported scheme. |
web+tasks://example.test/review | Reject the host-bearing form, which this application does not support. |
web+tasks:review?mode=edit | Reject the query string under this application's rules. |
Also open /app/open/?target=web%2Btasks%3Areview directly and confirm that the page accepts the recovered target. Test an empty target and duplicate target parameters; neither should trigger a task action. Encoding the plus sign matters: a literal + in a query parameter can be interpreted as a space.
These are application tests, not proof that a browser will dispatch every input through a registered handler. A browser or operating system may reject or normalize malformed inputs before the page receives them.
Advertisement
2. Test registration and an actual launch
- Check the manifest and handler route on the staging HTTPS origin. Ensure the route is within the app's configured scope and can be loaded directly.
- Install or otherwise register the PWA using the procedure documented for the target browser. Record any prompt and the user's choice; do not assume registration is automatic or identical across browsers.
- From a separate test page or another application, activate a link to
web+tasks:review. Confirm which application receives it, whether a permission or application-choice prompt appears, and whether the handler page receives and accepts the intended target. - Repeat after declining a prompt, choosing a different handler where the platform allows it, and removing the PWA or its registration. Confirm that users can still reach the ordinary HTTPS fallback and paste the URL manually. Exact controls and prompts vary by platform.
- Repeat after updating the manifest and reinstalling or refreshing the app as required by that browser. Check the installed registration rather than assuming a changed manifest immediately updates it.
Test only on devices and accounts you control. If a launch does not reach the page, inspect the platform's handler registration and permission settings before debugging the page's parsing code. If it reaches the page but is rejected, inspect the received parameter with synthetic data and test the validation separately.
Compatibility, permission, and deployment checks
Protocol-handler support and its details are browser- and platform-dependent. The browser may ask the user for permission or let them choose a default application; a user can decline or change that choice. A previously installed competing handler can also affect the result.
Use HTTPS for the deployment and check the target browser's current secure-context, installation, manifest, and operating-system requirements. Do not treat local development behavior as evidence that a production origin will register successfully. Manifest-declared PWA handlers and navigator.registerProtocolHandler() are different registration mechanisms; verify the documentation for the one you actually use.
Before publishing or shipping, consult the current W3C specification and official documentation for every supported browser, then run the plan on the actual browser–OS combinations you claim to support. Those sources and current compatibility details were not available to verify in this run, so this article does not provide a support matrix or promise that the example registers everywhere.
Common Mistakes
- Testing only the handler page: Directly opening the HTTPS route verifies page logic, not OS registration or link dispatch.
- Putting raw URLs into a query string: Characters such as
+,&, and#can change how parameters are parsed. Encode the complete target when constructing a manual test URL. - Treating a parsed URL as trusted: Parsing does not authorize access or guarantee that the identifier meets your application's rules.
- Assuming malformed input reaches the app unchanged: A browser or operating system may reject or transform it first. Test malformed values directly in the fallback as well as through launch paths.
- Providing no fallback: Unsupported browsers, denied permissions, and competing handlers can all prevent the intended launch.
- Using sensitive data in test URLs: URLs can be retained in browser history, logs, or other diagnostics. Use fictional identifiers and avoid putting secrets in the protocol URL.
Best Practices
Keep the handler route narrow: validate the scheme and the fields your application actually supports, show clear errors, and require authorization before accessing resources. Keep the fallback available independently of registration, and include it in release testing. Recheck official implementation guidance whenever your supported browser or operating-system matrix changes.
Conclusion
A reliable release test separates registration, launch, parameter decoding, validation, and authorization. Verify each on your supported platforms, and make the HTTPS fallback useful even when the protocol handler never starts.
What would your domain sell for?
A free TidyURLs account unlocks the Domain Estimator. It prices a name from 191,011 real domain sales.