Localization with destinations
Destinations don’t manage locales. Each path maps to a single experience. The Destinations Delivery API doesn’t support locale-aware routing, a locale parameter, or automatic redirects based on browser language.
Your application must resolve the locale before requesting an experience. You can store the locale in the URL path, the domain, or a cookie.
Your application is responsible for:
- Determining the locale from the incoming request — URL path prefix, domain, etc.
- Removing the locale prefix from the path before calling the Destinations Delivery API.
- Rendering the hydrated experience returned by the API.
How it works
The Destination API resolves the path and returns either a hydrated experience or a redirect. Your request handler must check for a redirect before rendering the experience.
Pattern 1: Single-segment path prefix
The most common setup. One segment at the start of the URL identifies the locale. Remove the locale segment before resolving the experience.
Next.js example
Pattern 2: Language-region prefix
Same as Pattern 1, but the segment encodes both language and region. The extraction logic is identical — the segment just has a different shape.
Pattern 3: Two-segment country/language prefix
Some sites use two separate segments for country and language. Remove both before calling the API.
Pattern 4: Domain or subdomain locale
Use this pattern when each locale has a dedicated domain or subdomain. Pass the request path to the Destination API unchanged — no need to remove the locale prefix.
Determine the locale from the incoming request’s host. Depending on your hosting configuration, read the host from the Host header, the X-Forwarded-Host header, or a platform-specific equivalent.
Sitemap and hreflang
The destination sitemap endpoint returns locale-agnostic paths:
To generate a locale-aware XML sitemap, expand each path into one entry per locale and add hreflang alternates so search engines understand the relationship between them.
Path-prefix locales (Patterns 1, 2, and 3)
This produces one <url> block per locale per path, each annotated with alternates for every other locale:
Domain-based locales (Pattern 4)
This produces the same hreflang structure, but with full domain URLs: