home / skills / fusengine / agents / nextjs-i18n

This skill streamlines Next.js 16 internationalization with next-intl or a DIY approach, delivering type-safe messages, locale routing, and formatting.

npx playbooks add skill fusengine/agents --skill nextjs-i18n

Review the files below or copy the command above to add this skill to your agents.

Files (24)
SKILL.md
5.8 KB
---
name: nextjs-i18n
description: Next.js 16 internationalization with next-intl or DIY. Use when implementing i18n, translations, localization, multilingual, language switch, locale routing, or formatters.
versions:
  next-intl: 4.0
  nextjs: 16
user-invocable: true
references: references/installation.md, references/pages-router.md, references/routing-setup.md, references/routing-config.md, references/translations.md, references/formatting.md, references/navigation.md, references/server-components.md, references/client-components.md, references/middleware-proxy.md, references/error-files.md, references/configuration.md, references/plugin.md, references/extraction.md, references/messages-validation.md, references/typescript.md, references/testing.md, references/integrations.md, references/seo.md, references/core-library.md, references/runtime-requirements.md, references/diy-dictionaries.md, references/diy-locale-detection.md
related-skills: nextjs-16, solid-nextjs
---

# Next.js 16 Internationalization

Complete i18n solution with next-intl or DIY dictionary approach.

## Agent Workflow (MANDATORY)

Before ANY implementation, use `TeamCreate` to spawn 3 agents:

1. **fuse-ai-pilot:explore-codebase** - Analyze existing i18n setup and message files
2. **fuse-ai-pilot:research-expert** - Verify latest next-intl docs via Context7/Exa
3. **mcp__context7__query-docs** - Check locale config and patterns

After implementation, run **fuse-ai-pilot:sniper** for validation.

---

## Overview

### When to Use

- Building multilingual Next.js 16 applications
- Need locale-based routing with `[locale]` dynamic segment
- Implementing language switcher and URL localization
- Formatting dates, numbers, currencies, and relative times per locale
- SEO optimization with hreflang tags and localized metadata
- Supporting right-to-left (RTL) languages

### Why next-intl

| Feature | Benefit |
|---------|---------|
| App Router native | Full Server Components support |
| Type-safe messages | TypeScript autocompletion for keys |
| ICU MessageFormat | Pluralization, gender, select expressions |
| Async message loading | Load translations on-demand per locale |
| proxy.ts compatible | Works with Next.js 16 proxy pattern |
| Rich formatting | Dates, numbers, lists, relative time |

---

## Two Approaches

### 1. next-intl (Recommended)

Full-featured library with routing, formatting, and type safety. Best for production applications needing comprehensive i18n support.

### 2. DIY Dictionary

Lightweight approach using dynamic imports for simple translation needs. Good for projects wanting minimal dependencies.

---

## SOLID Architecture

### Module Structure

All i18n code organized in `modules/cores/i18n/`:

- **config/** - Routing configuration, locale definitions
- **interfaces/** - TypeScript types for messages and locales
- **services/** - Request handlers, message loaders
- **messages/** - JSON translation files per locale

### File Locations

- `src/modules/cores/i18n/src/config/routing.ts` - Locale routing config
- `src/modules/cores/i18n/messages/en.json` - English translations
- `src/modules/cores/i18n/messages/fr.json` - French translations
- `proxy.ts` - Locale detection and redirect logic

---

## Routing Patterns

### Locale Segment

All routes prefixed with `[locale]` dynamic segment:

- `/en/about` → English about page
- `/fr/about` → French about page
- `/` → Redirects to default locale

### Navigation Components

Use localized navigation from next-intl for automatic locale handling:

- **Link** - Locale-aware anchor links
- **redirect** - Server-side locale redirect
- **usePathname** - Current path without locale
- **useRouter** - Programmatic navigation

---

## Reference Guide

| Need | Reference |
|------|-----------|
| Initial setup | [installation.md](references/installation.md), [routing-setup.md](references/routing-setup.md) |
| Route config | [routing-config.md](references/routing-config.md), [middleware-proxy.md](references/middleware-proxy.md) |
| Translations | [translations.md](references/translations.md), [messages-validation.md](references/messages-validation.md) |
| Formatting | [formatting.md](references/formatting.md) |
| Components | [server-components.md](references/server-components.md), [client-components.md](references/client-components.md) |
| Navigation | [navigation.md](references/navigation.md) |
| TypeScript | [typescript.md](references/typescript.md) |
| SEO | [seo.md](references/seo.md) |
| Testing | [testing.md](references/testing.md) |
| DIY approach | [diy-dictionaries.md](references/diy-dictionaries.md), [diy-locale-detection.md](references/diy-locale-detection.md) |

---

## Message Formatting

### ICU MessageFormat

- **Pluralization** - `{count, plural, one {# item} other {# items}}`
- **Select** - `{gender, select, male {He} female {She} other {They}}`
- **Rich text** - Support for bold, italic, links in messages

### Formatters

- **formatDate** - Locale-aware date formatting
- **formatNumber** - Currency, percentages, decimals
- **formatList** - Conjunction/disjunction lists
- **formatRelativeTime** - "2 hours ago", "in 3 days"

---

## Best Practices

1. **Type-safe keys** - Use TypeScript for message key autocompletion
2. **Namespace messages** - Organize by feature/page for maintainability
3. **Server-first** - Load translations on server, avoid client bundles
4. **SEO hreflang** - Add alternate links for all locales
5. **RTL support** - Use `dir` attribute for right-to-left languages
6. **Fallback locale** - Configure default for missing translations

---

## Error Handling

### Special Files

Localized error and loading states require specific handling:

- `[locale]/error.tsx` - Localized error boundary
- `[locale]/not-found.tsx` - Localized 404 page
- `global-error.tsx` - Root error fallback

See [error-files.md](references/error-files.md) for complete patterns.

Overview

This skill provides a complete Next.js 16 internationalization blueprint using next-intl or a lightweight DIY dictionary approach. It focuses on locale routing, type-safe message management, formatting utilities, and SEO-friendly localization patterns. The content maps to a SOLID module layout and includes routing, message loading, formatting, and error handling best practices.

How this skill works

The skill inspects the app router and introduces a [locale] dynamic segment to route pages per locale, with server-side redirects to a default locale. It integrates next-intl for type-safe message loading, ICU message formatting, and locale-aware formatters, or it offers a DIY dynamic-import dictionary loader for minimal-dependency projects. It also provides proxy and middleware patterns for locale detection, plus hooks and utilities for navigation and programmatic locale changes.

When to use it

  • Building multilingual Next.js 16 applications with locale-aware routing
  • You need type-safe translations, pluralization, and rich ICU messages
  • Implementing language switchers, localized URLs, and hreflang SEO
  • Formatting dates, numbers, currencies, lists, and relative time per locale
  • Supporting right-to-left (RTL) languages and localized error pages

Best practices

  • Organize i18n code under a dedicated module (config, interfaces, services, messages)
  • Prefer server-first translation loading to reduce client bundle size
  • Use TypeScript types for message keys to get autocompletion and validation
  • Namespace messages by feature or page for maintainability
  • Add hreflang links and localized metadata for SEO
  • Provide a fallback locale and explicit RTL dir handling

Example use cases

  • Full production app using next-intl: type-safe messages, async loaders, and rich formatters
  • Small site using DIY dictionaries with dynamic imports and simple locale detection
  • E-commerce site with currency and number formatting plus locale-based routing
  • Content site with SEO hreflang tags, localized metadata, and server-rendered translations
  • App requiring localized error pages and per-locale loading/error boundaries

FAQ

When should I choose next-intl over a DIY approach?

Use next-intl for production apps that need robust formatting, type safety, async loading, and full App Router support; choose DIY for minimal dependencies or very small translation sets.

How do I handle missing translations?

Configure a fallback locale on the server, validate message files during build, and provide runtime fallbacks or logging for missing keys.