navigator.deprecatedReplaceInURN(urnOrConfig, replacements) substitutes placeholders inside the browser-mapped URL for an opaque URN or FencedFrameConfig (MDN). JavaScript never sees that URL.
Pass the required arguments shown below. Check return values and browser support before you rely on the result.
Syntax
Call navigator.deprecatedReplaceInURN. Start with this line.
API missing
(or "Blocked invalid keys: foo" when the API exists)
How It Works
List the keys. Scan every property name in replacements.
Filter invalid ones. Anything not ${…} / %%…%% is blocked.
Return a clear message. Better than a raw TypeError in app logs.
Still try/catch. Bad URN / config can also throw.
Example 5 — Beginner Production Guard
Remind teams this is a temporary ad-tech bridge, not a general URL API.
JavaScript
function shouldUseDeprecatedReplaceInURN(options) {
if (!options || !options.migratingFencedFrameCreatives) {
return "Skip — not migrating fenced-frame ad creatives";
}
if (typeof navigator.deprecatedReplaceInURN !== "function") {
return "Skip — API unavailable in this browser";
}
return "Legacy only — prefer not to adopt; API is deprecated";
}
console.log(shouldUseDeprecatedReplaceInURN({ migratingFencedFrameCreatives: false }));
console.log(shouldUseDeprecatedReplaceInURN({ migratingFencedFrameCreatives: true }));
Skip — not migrating fenced-frame ad creatives
Skip — API unavailable in this browser
(or the legacy-only message if the API exists)
How It Works
Default to skip. Normal apps should never enter this path.
Require an explicit migration flag. Avoid accidental calls.
Detect the API. Missing means you cannot (and need not) use it.
Prefer exit. Even when available, treat it as legacy — not a feature to build on.
Compatibility
Browser Support
navigator.deprecatedReplaceInURN() is Deprecated (to be removed), Experimental, and not Baseline. Limited Chromium exposure (roughly Chrome / Edge 128+) for Privacy Sandbox / fenced-frame work; Firefox and Safari do not support it. Do not depend on it.
Bottom line: Recognize the API for literacy. Feature-detect if you must maintain old ad-tech code, but plan to remove it — MDN marks it for removal.
Frequently Asked Questions
It substitutes specified placeholder strings inside the browser-mapped internal URL for an opaque URN or FencedFrameConfig — without exposing that URL to JavaScript.
Both. MDN marks it Deprecated (to be removed) and Experimental. Chrome is withdrawing related Privacy Sandbox / fenced-frame APIs. Do not use it in new code; everyday apps never need it.
Mainly ad tech providers who needed temporary creative URL substitution inside fenced frames / Protected Audience. Normal web apps should skip it.
Replacement keys must use ${string} or %%string%%. Other formats throw TypeError. If a correctly formatted key is missing from the URL, the Promise still fulfills and that key is skipped.
A Promise that fulfills with undefined when the call succeeds.
No. The content URL is mapped internally by the browser and is not accessible via JavaScript — that is why substitution happens through this API instead of editing a public URL string.