Skip to main content
skill CX Codex

frontend-internationalization-best-practices — Claude Code skill

frontend-internationalization-best-practices is a Claude Code skill with best practices for React Router and remix-i18next, covering middleware, locale detection, and SSR hydration sync.

MIT 195 installs ★ 92 updated 2026-02-01

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code
Open on GitHub

What frontend-internationalization-best-practices does

This skill provides targeted guidelines for setting up internationalization in React Router projects powered by remix-i18next. It defines patterns for initializing createI18nextMiddleware, structuring translation files inside app/locales, and handling namespace splits for varying application sizes.

Included instructions cover resource routes like /api/locales/:lng/:ns with HTTP cache headers, client-side detection via htmlTag, and wiring I18nextProvider inside the SSR entry. It also directs loaders to consume bound t() instances using getFixedT.

The skill strictly targets the remix-i18next ecosystem inside React Router framework mode; projects using alternative localization engines will find little use here.

What it helps with

  • configure remix-i18next middleware with cookie persistence
  • structure locale folders and multi-namespace translation dictionaries
  • align SSR locale states with HTML root attributes and client hydration
  • expose localized JSON payloads through a cached resource route

Example prompts for the agent

  • Configure createI18nextMiddleware for React Router with cookie detection
  • Implement a resource route at /api/locales/:lng/:ns with caching headers
  • Sync the active locale between root loader and the html tag attributes

How to install frontend-internationalization-best-practices

1Skills CLI (Vercel)

npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code

2Manually: put the files in place

~/.claude/skills/frontend-internationalization-best-practices/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/frontend-internationalization-best-practices/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about frontend-internationalization-best-practices

How to install frontend-internationalization-best-practices in Claude Code?

Run npx skills add sergiodxa/agent-skills --skill frontend-internationalization-best-practices -a claude-code. The definition will be placed into ~/.claude/skills/frontend-internationalization-best-practices/SKILL.md.

What core libraries does this skill guide?

It centers on React Router framework mode paired with remix-i18next.

Where does it suggest persisting the chosen locale?

It recommends storing the language in a cookie or session header for speed, while maintaining user preferences in a database when authenticated.

Source text

SKILL.md · MIT
---
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 `<html lang dir>`.

```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
<I18nextProvider i18n={getInstance(routerContext)}>
  <ServerRouter context={entryContext} url={request.url} />
</I18nextProvider>
```

### 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.

© sergiodxa · MIT · sergiodxa/agent-skills

Similar skills

All skills for Frontend and UI →

From the same set11

The whole set →
frontend-react-best-practices frontend-react-best-practices — a skill with 33 React performance rules: fewer wasted re-renders, leaner bundles, cleaner component composition. Useful while writing or refactoring components. CX Codex +1 1,200installs frontend-accessibility-best-practices frontend-accessibility-best-practices is a Claude Code skill with WCAG patterns for React components. It activates when building UI, forms or interactive elements, or reviewing code for accessibility. CX Codex +1 926installs frontend-tailwind-best-practices frontend-tailwind-best-practices is a Claude Code skill with 10 Tailwind CSS rules for component styling, covering stack utilities, gap spacing, dark color schemes, and className merging. CX Codex +1 470installs frontend-react-router-best-practices frontend-react-router-best-practices is a Claude Code skill that sets React Router architecture rules for parallel loaders and secure mutation handlers without client waterfalls. CX Codex +1 406installs frontend-js-best-practices frontend-js-best-practices provides 17 performance and style rules for JavaScript and TypeScript. Helps agents optimize loops, reduce algorithmic complexity, and avoid array mutations. CX Codex +1 341installs ruby-on-rails-best-practices ruby-on-rails-best-practices is a Claude Code skill that provides 16 Basecamp Rails conventions for models, thin controllers, background jobs, and Turbo broadcasts. CX Codex +1 283installs frontend-async-best-practices frontend-async-best-practices is a Claude Code skill for eliminating async waterfalls by parallelizing independent requests instead of awaiting them sequentially. CX Codex +1 228installs skill-writing-best-practices skill-writing-best-practices provides guidelines and structural patterns for authoring AI agent skills. Useful when packaging codebase conventions or reviewing rules in skills/. CX Codex +1 176installs

Project sponsors

Companies that keep this analytics open