next-intl-routing-and-navigation
Next Intl Routing and Navigation
Use this skill when the task is primarily about URL structure, locale negotiation, or locale-aware navigation.
Scope
- App Router locale routing setup
defineRouting,createMiddleware,createNavigationlocalePrefix,localeDetection,localeCookie,alternateLinks- localized pathnames, domains,
getPathname, and base-path-aware URL generation - locale switchers and CMS-driven localized URLs
Routing cues
defineRouting,createNavigation,Link,useRouter,usePathname,getPathname, locale switcher, domain routing, pathnames,proxy.ts,middleware.ts,NEXT_LOCALE,hreflang-> use this skill- ICU messages,
useTranslations,useFormatter, rich text, message validation -> usenext-intl-messages-and-formatting getRequestConfig,setRequestLocale,getTranslations, metadata, Server Actions, testing -> usenext-intl-server-runtime- plugin setup, TypeScript augmentation, Crowdin,
useExtracted, message loading strategy -> usenext-intl-workflows-and-tooling
Workflow
- Read references/routing-architecture.md first.
- If the task touches locale switchers, cookies, alternate links, or
getPathname, read references/locale-switchers-and-alternate-links.md. - If the task touches localized slugs, domains, or SEO-facing URLs, read references/pathnames-domains-and-cms.md.
- Keep
routing.ts,proxy.tsormiddleware.ts, navigation helpers, and locale-switcher behavior derived from one shared routing object. - Validate any incoming locale with
hasLocale(...)before treating it as trusted.
Guardrails
- Keep
src/i18n/routing.tsas the single routing source of truth. - Keep middleware matcher coverage broad enough for localized pages, but exclude
api,trpc,_next,_vercel, and static files. - Do not duplicate locale lists, prefix rules, or pathname maps across files.
- Treat
localePrefix: 'as-needed'andlocalePrefix: 'never'as behavioral changes, not cosmetic ones. They affect redirects, cookies, alternate links, and locale persistence. - Prefer
useRouter().replace({pathname, params}, {locale})for in-place locale switchers.Link locale=...always prefixes and disables prefetch. getPathname(...)is the canonical localized pathname builder, but it returns the bare pathname withoutbasePath.- Translate only static route segments with
pathnames. Keep dynamic slugs sourced from the CMS or app data model. - Disable or customize automatic alternate links when URLs vary outside the routing config, availability differs by locale, or CMS-driven slugs are involved.
Canonical APIs
defineRoutingcreateMiddlewarecreateNavigationhasLocalegetPathname
Maintenance
- Snapshot date: 2026-03-10
- Package snapshot:
next-intl@4.8.3published 2026-02-16
References
More from dobroslavradosavljevic/skills
base-ui-typescript-surface
Use for Base UI namespace contracts, change event types, generic render types, and wrapper typing patterns.
4base-ui-basic-primitives
Use for simple primitives with low integration complexity (Avatar, Button, Meter, Progress, Scroll Area, Separator).
4base-ui-root-providers
Use for CSP Provider, Direction Provider, and useDirection when wiring Base UI at the app root or across portals.
4base-ui-menus-navigation-and-toast
Use for Menu, Context Menu, Menubar, Navigation Menu, Toolbar, Toast, and shared command-surface patterns such as detached triggers and menu payloads.
4base-ui-forms-and-validation
Use for Base UI Field/Form primitives, validation flows, form controls, and advanced Number Field, Slider, and RadioGroup behavior.
4base-ui-disclosure-and-tabs
Use for stateful visibility components (Accordion, Collapsible) and tab navigation semantics.
4