# Frontend internationalization best practices > Use when adding locales or language switching to a React Router app with remix-i18next. Internationalization best practices for React Router framework mode using remix-i18next. Use when setting up locales, middleware, resource routes, or language switching. ## Facts - Type: Agent skill - Discipline: Engineering - Author: Sergio Xalambri (https://github.com/sergiodxa) - Upstream: https://github.com/sergiodxa/agent-skills/blob/main/skills/frontend-internationalization-best-practices/SKILL.md - Source file: https://raw.githubusercontent.com/sergiodxa/agent-skills/main/skills/frontend-internationalization-best-practices/SKILL.md (3456 bytes, sha256:1d8cc0034ce63d3e9dee0ace9cbe14c8379ecfdd57ab89c0d37ff78f523d4c90) - Licence: MIT - Upstream copy last changed: 2026-09-17 - Status: listed, not yet ruled on by the curator ## Use it I want to use the Frontend internationalization best practices skill by Sergio Xalambri. This is what it does, in the author's own words: Internationalization best practices for React Router framework mode using remix-i18next. Use when setting up locales, middleware, resource routes, or language switching. Download the whole folder at https://github.com/sergiodxa/agent-skills/tree/main/skills/frontend-internationalization-best-practices, SKILL.md and every file beside it, into your skills directory: ~/.claude/skills/frontend-internationalization-best-practices/ for Claude Code, ~/.agents/skills/frontend-internationalization-best-practices/ for Codex, ~/.cursor/skills/frontend-internationalization-best-practices/ for Cursor. Get it from the author's repo, not from startupskills.dev. Then tell me the path you installed it to and how to invoke it. Nothing here is vendored: install from the author's repo, not from this site. A verbatim copy of the author's file follows for reading, under the licence reproduced after it; the current file is in the author's repo. ## Links - Page: https://startupskills.dev/sergiodxa/frontend-internationalization-best-practices - Author: https://startupskills.dev/sergiodxa - Index: https://startupskills.dev/llms.txt ## The file itself --- name: frontend-internationalization-best-practices description: Internationalization best practices for React Router framework mode using remix-i18next. Use when setting up locales, middleware, resource routes, or language switching. --- # Internationalization Best Practices Guidelines for building a React Router i18n setup with `remix-i18next`. Focuses on middleware detection, locale storage, type safety, and client/server synchronization. ## When to Apply - Adding i18n to a React Router app - Wiring `remix-i18next` middleware - Implementing language switching or locale detection - Serving locale resources from `/api/locales` ## Rules Summary ### Setup & Middleware (CRITICAL) #### setup-middleware - @rules/setup-middleware.md Configure `createI18nextMiddleware` and type-safe resources. ```ts export const [i18nextMiddleware, getLocale, getInstance] = createI18nextMiddleware({ detection: { supportedLanguages: ["es", "en"], fallbackLanguage: "en", cookie: localeCookie, }, i18next: { resources }, plugins: [initReactI18next], }); ``` #### locales-structure - @rules/locales-structure.md Define locale resources per language and re-export. ```ts // app/locales/en/translation.ts export default { title: "Example" }; ``` ### Namespaces (HIGH) #### namespaces-strategy - @rules/namespaces-strategy.md Use a single namespace for small apps; multiple namespaces for large apps. ```ts // Large app: common + route namespaces export default { common, home, notFound }; ``` ### Locale Detection & Persistence (CRITICAL) #### locale-detection - @rules/locale-detection.md Prefer cookie/session for speed, with DB as source of truth. ```ts export const [i18nextMiddleware, getLocale] = createI18nextMiddleware({ detection: { cookie: localeCookie, fallbackLanguage: "en" }, }); ``` #### language-switcher - @rules/language-switcher.md Store locale in cookie/session and keep it in sync. ```ts return data( { locale }, { headers: { "Set-Cookie": await localeCookie.serialize(locale) } }, ); ``` ### Client & Server Integration (CRITICAL) #### root-locale-sync - @rules/root-locale-sync.md Send locale to the UI and sync ``. ```tsx export async function loader({ context }: Route.LoaderArgs) { let locale = getLocale(context); return data( { locale }, { headers: { "Set-Cookie": await localeCookie.serialize(locale) } }, ); } ``` #### entry-client-init - @rules/entry-client-init.md Initialize i18next client with `htmlTag` detection. ```ts i18next.init({ detection: { order: ["htmlTag"], caches: [] } }); ``` #### entry-server-provider - @rules/entry-server-provider.md Reuse the middleware instance in SSR with `I18nextProvider`. ```tsx ``` ### Resource Routes & Caching (HIGH) #### locales-resource-route - @rules/locales-resource-route.md Serve `/api/locales/:lng/:ns` with validation and cache headers. ```ts return data(namespaces[ns.data], { headers }); ``` ### UI Usage (MEDIUM) #### use-bound-t-in-loader - @rules/use-bound-t-in-loader.md Use the bound `t()` in loaders and `useTranslation` in components. ```ts let t = getInstance(context).getFixedT(locale); ``` ### Not Found (MEDIUM) #### not-found-i18n - @rules/not-found-i18n.md Provide a 404 route so middleware runs and translations load. ## Licence of the file above The file above is https://raw.githubusercontent.com/sergiodxa/agent-skills/main/skills/frontend-internationalization-best-practices/SKILL.md, by Sergio Xalambri, reproduced without changes. - Source: https://github.com/sergiodxa/agent-skills/blob/main/skills/frontend-internationalization-best-practices/SKILL.md - Copyright: Copyright (c) 2026 Sergio Xalambrí - Licence: MIT, https://raw.githubusercontent.com/sergiodxa/agent-skills/main/LICENSE The repo's licence file, verbatim from https://raw.githubusercontent.com/sergiodxa/agent-skills/main/LICENSE: MIT License Copyright (c) 2026 Sergio Xalambrí Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.