Server-Side Translation Loading and Message Catalogs
Load namespaced message catalogs in server components without shipping all locales to the client.
Why Server-Side Translation Loading Matters
In Next.js 15 with the App Router, server components run exclusively on the server. This gives us a powerful opportunity: we can load translation files at request time without ever sending unused locale bundles to the client.
The naive approach — importing all translations at build time and bundling them into the client — causes several problems:
- Large JavaScript bundles that slow initial page load
- All locale strings shipped even when only one locale is active
- No ability to lazy-load translations per route or namespace
The server-side approach keeps translation data on the server and delivers only the rendered HTML to the client, keeping bundles lean.
Understanding Message Catalogs and Namespaces
A message catalog is a structured file (JSON, YAML, or similar) containing key-value pairs for a specific locale. Namespacing breaks catalogs into logical domains so you only load what a given page or component actually needs.
A typical project structure might look like:
messages/en/common.json— shared UI strings (buttons, labels)messages/en/home.json— homepage-specific stringsmessages/en/dashboard.json— dashboard stringsmessages/tr/common.json— Turkish equivalents
When a server component for the dashboard renders, it loads only dashboard.json and common.json for the active locale — not the entire catalog tree.
All lessons in this course
- Locale Detection and Subpath Routing with Middleware
- Server-Side Translation Loading and Message Catalogs
- Localized Metadata, Sitemaps, and hreflang
- Formatting Dates, Numbers, and Plurals by Locale