agentleFS
zulalnbzulalnb/skills/next-intl-app-router/SKILL.md

next-intl-app-router

Skill0 starsChanged 3 months agoMITView on GitHub

Comprehensive guidelines for Next.js App Router, next-intl i18n routing, catching unmatched routes, and multi-directional (LTR/RTL) layout setup.

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. liuchiawei/agent-skills★ 2same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All localized pages MUST live inside src/app/[locale]/.

    line 26
  2. Very specific:

    MUST extract locale from params (handle async params in Next.js 15+).

    line 75
  3. Very specific:

    MUST validate locale against supported list (['tr', 'en', 'ar']) using notFound() if invalid.

    line 76
  4. Very specific:

    MUST dynamically set <html lang={locale} dir={isRtlLocale(locale) ?

    line 77
  5. Very specific:

    MUST wrap the layout with NextIntlClientProvider using messages retrieved via getMessages() from next-intl/server.

    line 78
  6. Distinctive:

    MUST use Tailwind CSS Logical Properties for alignment to prevent broken layouts when switching between LTR and RTL languages (e.g., …

    line 82
  7. Very specific:

    MUST import Link, redirect, useRouter, and usePathname from @/i18n/navigation (or next-intl/navigation), NEVER directly from next/link or …

    line 89

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Next.js App Router + next-intl Complete Skill

1. Directory Structure & File Placement

  • Root Directory (src/app/):
    • page.tsx: Handles root redirects if middleware is bypassed or static export is used. MUST redirect to default locale (/tr).
    • not-found.tsx: Global catch-all 404 page for unmatched routes outside any locale context (e.g., /unknown.txt).
    • middleware.ts: Handles dynamic locale detection and routing at the edge.
  • Locale Directory (src/app/[locale]/):
    • All localized pages MUST live inside src/app/[locale]/.
    • layout.tsx: Root localized layout. Configures html lang and dir (RTL/LTR).
    • page.tsx: Main localized entry page.
    • error.tsx & not-found.tsx: Must reside inside [locale] to retain language and RTL context during error states.
    • [...rest]/page.tsx: Catch-all route to handle invalid paths inside a locale and trigger notFound().

2. Root Redirects & Catch-All Page Rules

src/app/page.tsx (Root Page)

import { redirect } from 'next/navigation';

// Executed as fallback for static export or direct root access
export default function RootPage() {
  redirect('/tr'); // Default locale is 'tr'
}

src/app/not-found.tsx (Global 404 Page)

'use client';

import Error from 'next/error';

// Renders when a non-localized route (e.g. `/unknown.txt`) is requested,
// or when root layout validation fails before entering `[locale]`.
export default function GlobalNotFound() {
  return (
    <html lang="en">
      <body>
        <Error statusCode="{404}"/>
      </body>
    </html>
  );
}

src/app/[locale]/[...rest]/page.tsx (Unmatched Route Handler)

import { notFound } from 'next/navigation';

export default function CatchAllPage() {
  notFound();
}

3. Root Layout (src/app/[locale]/layout.tsx) & RTL Support

  • MUST extract locale from params (handle async params in Next.js 15+).
  • MUST validate locale against supported list (['tr', 'en', 'ar']) using notFound() if invalid.
  • MUST dynamically set <html lang={locale} dir={isRtlLocale(locale) ? 'rtl' : 'ltr'}> (e.g., set dir="rtl" for RTL languages like Arabic, Hebrew, Persian, or Urdu).
  • MUST wrap the layout with NextIntlClientProvider using messages retrieved via getMessages() from next-intl/server.

4. RTL & Tailwind Logical Properties

  • MUST use Tailwind CSS Logical Properties for alignment to prevent broken layouts when switching between LTR and RTL languages (e.g., Arabic, Hebrew):
    • Margins: ms-* / me-* (instead of ml-* / mr-*)
    • Padding: ps-* / pe-* (instead of pl-* / pr-*)
    • Positioning: start-* / end-* (instead of left-* / right-*)

5. Navigation & Data Patterns

  • MUST import Link, redirect, useRouter, and usePathname from @/i18n/navigation (or next-intl/navigation), NEVER directly from next/link or next/navigation.
  • Data fetching logic MUST be isolated in src/lib/data.ts. Server Components should call data functions directly without internal HTTP fetch().

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.