Skillshub nextjs-i18n
Best practices for multi-language handling, locale routing, and detection strategies across App and Pages Router. Use when adding i18n, locale routing, or language detection in Next.js. (triggers: middleware.ts, app/[lang]/**, pages/[locale]/**, messages/*.json, next.config.js, i18n, locale, translation, next-intl, react-intl, next-translate)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/nextjs-i18n" ~/.claude/skills/comeonoliver-skillshub-nextjs-i18n && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/nextjs-i18n/SKILL.mdsource content
Internationalization (i18n)
Priority: P2 (MEDIUM)
Maintain a single source of truth for locales and ensure SEO-friendly sub-path routing.
Implementation Guidelines
- Locale Routing: Follow the URL-first approach for SEO. Use dynamic segments in the App Router (e.g.,
) and theapp/[lang]/page.tsx
configuration ini18n
for the Pages Router.next.config.js - Library Selection: Use
for the App Router (modern) ornext-intl
/react-intl
for legacy apps.next-translate - Detection: Implement Middleware localization (in
) to detect user language frommiddleware.ts
headers or cookies and perform redirects.Accept-Language - Server-Side: Load translation
dictionaries in Server Components to keep the client bundle small. Usemessages/*.json
orgetMessages()
patterns.requestConfig - SEO: Ensure
tags are generated correctly in thehreflang
API for all translated routes.metadata - Static Generation: Use
to pre-render localized versions of static pages at build time.generateStaticParamsmodule.exports = { i18n: { locales: ['en', 'fr', 'vi'], defaultLocale: 'en', }, };
3. Library Specifics
For detailed setup with common libraries, refer to:
Anti-Patterns
- No hardcoded strings in JSX: Use translation keys; never commit raw text.
- No client-side translation bundles: Load dictionaries server-side with
.getMessages() - No mixed URL locale patterns: Use sub-paths or domains consistently.