Decisions

0002 · App Router and locales

Next.js App Router with a [locale] segment and a proxy for clean URLs.

A documentação técnica está em inglês.

Status: Accepted · 2026-11

Context

Version 1 used the Pages Router, rendered nothing on the server (_app returned null until mounted), and mixed three i18n systems: next-i18next (configured but not wired), react-i18next and a language stored in localStorage. Search engines saw an empty page in one language.

Decision

  • Move to the App Router. Every route lives under app/[locale]/, which is also the root layout, so <html lang> is correct per locale.
  • Portuguese has no URL prefix; /en and /es do. src/proxy.ts rewrites, canonicalizes /pt/…, and respects an explicit language cookie. No Accept-Language sniffing.
  • Landing and docs are Server Components rendered at build time; the app and the shared viewer are client islands inside static shells.

Consequences

  • Every marketing and docs page is indexable, localized and fast; hreflang alternates are generated.
  • A static export isn't possible (the proxy needs a runtime). Vercel or any Node host is required.
  • Unknown paths under a locale are caught by [...missing] to render that layout's not-found page.
Editar esta página no GitHub