Skip to content
Live

Building Multilingual Web Apps with Next.js

A practical guide to internationalisation in Next.js 14 using the App Router, next-intl, and hreflang tags for global SEO.

By Soren Lindqvist8 min read

The Case for i18n from Day One

Internationalisation is one of those features developers perpetually defer — until the product is live and refactoring costs are enormous. Building i18n into your architecture from the start is far cheaper than retrofitting it later.

URL Structure Matters for SEO

Google treats example.com/en/blog and example.com/fr/blog as separate pages. This means you get double the indexable content and can rank in multiple language markets simultaneously.

// middleware.ts — route all traffic through locale prefix
import createMiddleware from "next-intl/middleware";

export default createMiddleware({
  locales: ["en", "fr", "de", "es"],
  defaultLocale: "en",
  localePrefix: "always",
});

Setting Up next-intl

The next-intl library integrates cleanly with the App Router. Messages live in JSON files, and the useTranslations hook gives you type-safe access to them.

// app/[locale]/page.tsx
import { useTranslations } from "next-intl";

export default function HomePage() {
  const t = useTranslations("home");
  return <h1>{t("hero_title")}</h1>;
}

hreflang: The SEO Signal You Can't Skip

Without hreflang tags, Google may serve the wrong language version to users. Add them to every page's <head>:

<link rel="alternate" hreflang="en" href="https://example.com/en/blog/post" />
<link rel="alternate" hreflang="fr" href="https://example.com/fr/blog/post" />
<link rel="alternate" hreflang="x-default" href="https://example.com/en/blog/post" />

Key Considerations

  • Keep translation keys flat and descriptive — avoid deeply nested objects
  • Use ICU message format for plurals and interpolation
  • Always provide a fallback locale
  • Test with pseudo-localisation before real translations arrive

Internationalisation done right is invisible to users — they simply see content in their language, and your SEO benefits quietly compound.

Share

Written by

Soren Lindqvist

Engineer. Ships the TypeScript, Docker, and database pieces, usually after breaking them in production first.

language

Content Strategy for Multilingual Platforms

Building a content operation that scales across languages. From editorial workflows to translation memory, learn how global publications stay consistent.

Elena Marchetti8 min read
nextjs

Next.js App Router: Patterns That Actually Work

Real-world patterns for the Next.js App Router — parallel routes, intercepting routes, loading UI, error boundaries, and streaming with Suspense.

Soren Lindqvist11 min read
api

API Design Best Practices in 2024

Design APIs that developers love. Covers REST conventions, versioning strategies, error handling, pagination, and the OpenAPI specification.

Amara Osei10 min read