Locale route design
What you need to know
Locale routing places the language choice in the URL, such as /en/catalog. Validate the locale against a small allowlist before loading dictionaries or choosing a route.
By the end, you can: validate locale segment; choose fallback behavior.
Narrow the locale before access
type Locale='en'|'fa';function isLocale(value:string):value is Locale { return value==='en'||value==='fa';}console.log(isLocale('fr'));Expected behavior: false. This illustrates the future two-language allowlist, not the current publication policy.
How it works
In App Router, a dynamic app/[lang] segment can carry a locale through pages and layouts. In the proposed Next.js 16 lane await params and narrow the language to a supported set. Use a fixed dictionary map, not an arbitrary path derived from input. A site may redirect an unprefixed entry to a default or negotiated locale, but an explicitly chosen supported language must take precedence over a browser preference. Accept-Language values can be absent, malformed or weighted; use a reviewed negotiation library or a documented small policy instead of pretending a prefix split implements the standard. If Proxy performs routing, exclude metadata, static assets and already-prefixed pages to prevent loops. Decide whether unknown locale paths are not-found or handled by an explicit redirect; this fixture returns not-found for unsupported languages. Pages Router i18n configuration is a separate architecture. For the English-only V12 fixture only en is published; fa is an architectural example for a future genuine Persian translation, not a second published route.
An English-only root layout in a locale segment
import {notFound} from 'next/navigation';export default async function Layout({children,params}:{children:React.ReactNode;params:Promise<{lang:string}>}){ const {lang}=await params; if(lang!=='en') notFound(); return <html lang='en' dir='ltr'><body>{children}</body></html>;}Expected behavior: Use app/[lang]/layout.tsx as the root layout with no competing root layout. Only English is served in the staged fixture.
Common mistake
Do not redirect every visit based on IP or reapply a locale prefix to an already-prefixed route. Do not load arbitrary dictionary paths or mark English text as Persian.
Practice and verification
Build a route table for /, /en/catalog, /fa/catalog, /fr/catalog and /robots.txt. Specify which routes exist now and which require future translation. Test that the redirect chain terminates and asset routes are unaffected.
Scope: Proposed Next.js 16.x / React 19, Cache Components disabled unless noted. Framework and browser examples are staged; local standalone tests are reported separately. Exact dependency patches and platform contracts pending.
Further reading: I18N · Meta Files