navigator.deprecatedReplaceInURN() substitutes placeholders inside a browser-mapped fenced-frame URL for an opaque URN or FencedFrameConfig. Learn the purpose, allowed ${string} / %%string%% key formats, MDN examples, five labs, and why everyday sites can skip this API.
01
Kind
Method
02
Returns
Promise<undefined>
03
Status
Experimental
04
Audience
Ad tech / fenced frames
05
API family
Fenced Frame API
06
Placeholders
${name} / %%name%%
Fundamentals
Introduction
Fenced frames load privacy-sensitive content (often ads) without letting the embedder read the destination URL. A source such as Protected Audience runAdAuction() can return an opaque URN or a FencedFrameConfig, which you assign to a <fencedframe>. The real URL stays inside the browser.
Older ad systems still inject runtime values into creative URLs (campaign ids, sizes, and so on). deprecatedReplaceInURN() is a temporary bridge: it replaces allowed placeholders in that hidden URL so creatives keep working while teams migrate.
💡
Beginner takeaway
You will almost never call this in a normal blog, shop, or dashboard. Learn the shape so you can recognize it in Privacy Sandbox / ad docs — then move on unless you are migrating fenced-frame creatives.
Concept
Understanding the deprecatedReplaceInURN() Method
Input 1 — a FencedFrameConfig or opaque URN from an auction / similar source.
Input 2 — a replacements object whose keys are placeholders and values are substitute strings.
Allowed keys — ${string} or %%string%% only.
Missing placeholders — correctly formatted keys that are not in the URL are skipped; the Promise still fulfills.
Invalid keys / URN — can throw TypeError.
Temporary — named for migration; plan to leave it behind in new designs.
Four facts to remember about navigator.deprecatedReplaceInURN().
Returns
Promise
Fulfills undefined
Status
Experimental
Not Baseline
Keys
${} / %%
Strict formats
Audience
Ad tech
Fenced frames
Compare
📋 Editing a Normal URL vs Fenced URN Substitution
Normal page URL
Fenced URN / config
Can JS read the URL?
Yes (e.g. location.href)
No — mapped internally
How to substitute?
Build a new string yourself
deprecatedReplaceInURN()
Typical use
Everyday navigation / APIs
Privacy-preserving ads / creatives
Beginner apps
Common
Usually never needed
Hands-On
Examples Gallery
Examples follow MDN patterns. Prefer Try It Yourself — a real auction URN / FencedFrameConfig is rare outside Privacy Sandbox demos, so labs focus on detection, placeholder rules, and safe calling patterns.
📚 Getting Started
Detect the method and learn the only allowed placeholder formats.
Example 1 — Feature Detection
Check whether the temporary Fenced Frame helper exists.
API missing
(or "Blocked invalid keys: foo" when the API exists)
How It Works
Rejecting bad keys early avoids a TypeError from the browser.
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 "OK to feature-detect and call for temporary migration only";
}
console.log(shouldUseDeprecatedReplaceInURN({ migratingFencedFrameCreatives: false }));
console.log(shouldUseDeprecatedReplaceInURN({ migratingFencedFrameCreatives: true }));
navigator.deprecatedReplaceInURN() belongs to the experimental Fenced Frame API and is not Baseline. Support is limited to Privacy Sandbox / fenced-frame capable browsers. Always feature-detect and treat the method as a temporary migration aid for ad creatives.
✓ Experimental · Not Baseline
Navigator.deprecatedReplaceInURN()
Temporary helper — substitute ${} / %% placeholders in a mapped fenced-frame URL.
LimitedExperimental
Google ChromePrivacy Sandbox / Fenced Frame capable builds
Limited
Microsoft EdgeFollow Chromium Fenced Frame support
Limited
OperaFollow Chromium where available
Limited
Mozilla FirefoxTypically unavailable — feature-detect
Unavailable
Apple SafariTypically unavailable — feature-detect
Unavailable
Internet ExplorerNo Fenced Frame / this method
Unavailable
deprecatedReplaceInURN()Limited
Bottom line: Detect the method, validate placeholder keys, use it only for fenced-frame creative migration, and plan to remove the temporary bridge.
Wrap Up
Conclusion
navigator.deprecatedReplaceInURN() is an experimental, temporary way to substitute ${name} / %%name%% placeholders inside a browser-mapped fenced-frame URL. Detect it, validate keys, use it only for Privacy Sandbox creative migration, and keep it out of everyday app code.
Prefer modern Privacy Sandbox patterns for new work
❌ Don’t
Use this in ordinary beginner web apps
Expect to read the internal fenced URL from JavaScript
Pass free-form keys like "foo"
Assume Baseline / universal support
Build long-term architecture on this temporary bridge
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about deprecatedReplaceInURN()
Experimental fenced-frame URL substitution for ad-tech migration.
5
Core concepts
🔗01
Returns
Promise
Value
⚡02
Status
Experimental
Limited
📄03
Keys
${} or %%
Formats
🔒04
URL hidden
Browser-mapped
Privacy
🎯05
Scope
Ad tech bridge
Temporary
❓ 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.
MDN marks it Experimental and Limited availability (not Baseline). The word "deprecated" in the method name signals a temporary migration helper for ad tech — it is not listed as a Deprecated MDN status badge. Prefer Privacy Sandbox / Fenced Frame patterns designed for new work.
Mainly ad tech providers migrating older creative URL substitution into fenced frames / Protected Audience. Everyday web apps usually never need it.
Replacement keys must use ${string} or %%string%%. Other key 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 string editing a public URL.
Did you know?
If a placeholder key is correctly formatted but not present in the internal URL, the Promise still fulfills — the browser simply skips that substitution instead of failing.