6 Pitfalls of Building a Multilingual Site with Next.js 15: From Query Strings to URL Paths
I built a 150+ tool website with Next.js 15 on Cloudflare Pages (utlkit.com). Half the traffic was from China, half from elsewhere. Time to add i18n. I thought it would take a day. It took four, and I rewrote the approach three times. Why is i18n Harder Than You Think? A 100+ page tool site needs more than translated text. You need to handle: Layer Problem Routing Does the URL change on language…
Building a multilingual website with Next.js 15 can be challenging, with several pitfalls to be aware of. This story covers the author's experience of tackling these issues while creating a 150+ tool website on Cloudflare Pages.
The first pitfall, Pitfall 1: Nested Root Layout, occurs when switching languages on a page leads to a crash or blank screen. The root cause is that Next.js 15 App Router renders both app/layout.tsx and app/[locale]/layout.tsx, which can cause double HTML rendering and hydration issues. The solution is to return only children in the root layout file.
Pitfall 2: redirect() Doesn't Work with Static Export is another issue faced by the author. The problem arises when redirecting the root path / to /en/ or /zh-CN/ based on the user's browser language, but the redirect() function does not work in static export mode. The fix involves using client-side JavaScript to handle the redirection, with a noscript fallback to ensure compatibility with non-JS environments.
Finally, Pitfall 3: Passing Locale to generateMetadata is a mistake that causes all tool page titles to appear in English, regardless of the visitor's language preference. The root cause is that generateMetadata() receives params as an async promise, which can lead to undefined or error values. To fix this, the author uses the new Next.js 15 way of passing params, which resolves the issue and ensures the correct locale-specific metadata is displayed.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.