Skip to main content
These run in the site’s middleware to evaluate redirect rules, negotiate a locale, and read the visitor’s country.

routing/evaluate

@replohq/sdk/routing/evaluate Exports

routing/rules

@replohq/sdk/routing/rules

reploRedirect

Validates a redirect rule, returning it unchanged. Throws RedirectRuleValidationError carrying the first failing check’s message.
Also exported

routing/locale

@replohq/sdk/routing/locale

localeUrl

The URL of a logical path in another locale — the one primitive a language switcher and hreflang alternates need. Within the current host’s scope (or with no domains configured) it is the locale-prefixed path; a locale served by a different domain gets an absolute URL there, dropping the prefix when that domain serves only the one locale. Hidden-mode sites use the prefixed form too: the runtime converts an explicit locale prefix into a cookie plus a clean-URL redirect on arrival.
Overrides the visitor’s IP-derived country for testing geo behavior without a VPN — works identically in dev sandboxes and on the published site. At worst it lets a visitor pick which locale they see, which the locale cookie already allows deliberately.
Set by the runtime when a visitor explicitly picks a locale (a language switcher link, or landing on a locale-prefixed URL). Negotiation reads it ahead of any detection, so an explicit choice always wins.

reploLocaleRouting

Validates a locale routing config, returning it with every tag canonicalized and defaults applied. Throws LocaleRoutingValidationError carrying the first failing check’s message.
Also exported

routing/geo

@replohq/sdk/routing/geo

ipCountry

The visitor’s ISO 3166-1 alpha-2 country, or null when unknown. The override cookie wins so geo behavior is testable without a VPN — in dev sandboxes, where the Cloudflare header never exists, and on the published site alike. At worst the override lets a visitor pick which locale they see, which the locale cookie already allows deliberately.