Urgent.News

What's breaking now, across thousands of outlets.

Tech

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.

Also reported by 1 other outlet

Read the original at dev.to →

More in Tech

I Built 16 Browser-Based Developer Tools That Never Upload Your Data.

I Built 16 Browser-Based Developer Tools That Never Upload Your Data As a developer, I often find myself needing a quick tool for something small: Format some JSON Decode a JWT Encode a string with…

  • Developer created 16 browser-based tools without data upload
  • Utilities perform tasks like JSON formatting and Base64 encoding
  • Client-side processing ensures privacy and data security

What Broke When We Turned Government Open Data Into Agent-Callable Evidence

Government open data looks deceptively easy from a distance. Find an endpoint. Make a request. Normalize the JSON. Ship an API. That is enough for a demo.

  • HTTP response limits can cause discrepancies between reported and actual records
  • Fail-closed decision vocabulary recommended for address lookups with no permit records
  • Evidence envelope should include source info, scope, record details, decision state

C++ Tool That Extracts Text From Scrolling Screen Recordings

Palimpsest: I Built a C++ Tool That Extracts Text From Scrolling Screen Recordings (94% Accuracy, 323 FPS on a Laptop) Most of the code was AI-generated from a detailed architecture prompt.

  • C++ programmer develops Palimpsest tool
  • Achieves 94.56% accuracy, 323 FPS
  • Converts banking regulation videos to text

More from Monday 24 August →