Skip to solution
hardFrontend

How do you internationalize (i18n) a Next.js App Router app?

116 views
01

Understand the problem

Locale routing and translation in the App Router.

nextjsi18ninternationalizationrouting
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Nudge consolestandby

Stuck? Beam a request up — the console returns a conceptual nudge that guides your logic without spoiling the implementation.

03

Study the solution

The App Router has no built-in i18n routing (unlike Pages), so you use a [lang] dynamic segment plus middleware to detect/redirect by locale, and a library (next-intl, next-i18next) to load translations. generateStaticParams pre-renders each locale; metadata is localized per route.

Solution ready — 2 min read

Classified // press E to declassify

04

Read the code

Locale segment + static params
// app/[lang]/layout.tsx
export function generateStaticParams() {
  return [{ lang: 'en' }, { lang: 'fr' }, { lang: 'de' }];   // prerender each locale
}
export default async function Layout({ children, params }) {
  const { lang } = await params;
  return <html lang={lang}>{children}</html>;
}
// middleware redirects '/' → '/en' based on Accept-Language.
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.

Transmission complete // awaiting log

KEEP THE
STREAK ALIVE.

Dossier 93 of 95 decoded in the Next.js track. One more won't hurt.

Back to track