Most bilingual agency sites store the chosen language in localStorage or a cookie and swap the strings on the client. It is the fastest thing to build and it costs more than it looks.
Three costs
- A crawler only ever sees the default language. The other half of the content does not exist as far as search is concerned, because there is no URL to index.
- The cookie is a cookie. Now the site needs a consent banner, a consent record, and a paragraph in the privacy notice.
- The first paint is in the wrong language and then flips, which is exactly the kind of hydration flicker that makes a fast site feel unfinished.
What we do instead
The locale is a path segment: /en and /sr are real, prerendered routes with their own canonical URL, their own hreflang set and their own share image. A request without a locale is negotiated once from Accept-Language and redirected. Nothing is stored on the device, so there is nothing to consent to and no banner to dismiss.
01export function proxy(request: NextRequest) {02 const first = request.nextUrl.pathname.split('/')[1]03 if (isLocale(first)) return NextResponse.next()04 05 const url = request.nextUrl.clone()06 url.pathname = `/${negotiate(request.headers.get('accept-language'))}${…}`07 return NextResponse.redirect(url)08}The trade-off
A first-time visitor pays one redirect, and someone who prefers a language other than the one their browser advertises has to click. That is the whole cost. In exchange both languages are indexable, shareable and cacheable at the edge, and the privacy notice can say "this site sets no cookies" without a footnote.
Tags
- Privacy
- SEO
- i18n