v146 · Web APIs · TargetURL Demo
TargetURL Demo
This page registers a launchQueue consumer and displays the full LaunchParams object it receives. In Chrome 146, when a PWA is launched via file handling, LaunchParams.targetURL is now populated with the URL the app was launched at.
Checking launchQueue support…
API availability
launchQueue in window
checking…
LaunchParams.targetURL
checking…
last received LaunchParams
launchQueue.setConsumer(launchParams => { … })
status:waiting for launch…
targetURL:—
files.length:—
files[0].name:—
simulate file selection
Pick local files to simulate a launch (reads via File API — no real launchQueue)
Drop files here or click to select
No files selected
code
// Register as a file handler in web app manifest:
// {
// "file_handlers": [{
// "action": "/open",
// "accept": { "text/plain": [".txt"], "image/*": [".png", ".jpg"] }
// }]
// }
// Consume file handling launches in the app:
if ('launchQueue' in window) {
launchQueue.setConsumer(async launchParams => {
// Chrome 146: targetURL is now populated
const url = launchParams.targetURL;
// → e.g. "https://myapp.example/open"
// Previously this was null for file handling launches
if (!url) {
console.warn('targetURL null — running pre-Chrome 146?');
}
// Process each file
for (const fileHandle of launchParams.files) {
const file = await fileHandle.getFile();
const content = await file.text();
openDocument(file.name, content);
}
});
}