KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
▲

Next.js

Topic Hub & Articles

Next.js Intro

10 min

Next.js Installation

10 min

Next.js Routing

10 min

Next.js Pages

10 min

Next.js App Router

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Layouts

10 min

Next.js Linking and Navigating

10 min

Next.js Loading UI and Streaming

10 min

Next.js Error Handling

10 min

Next.js Data Fetching

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Server Actions

10 min

Next.js Rendering

10 min

Next.js CSS Modules

10 min

Next.js Image Optimization

10 min

Next.js Font Optimization

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Script Optimization

10 min

Next.js Static File Serving

10 min

Next.js Metadata

10 min

Next.js API Routes

10 min

Next.js Middleware

10 min

Recap Quiz

Gated

Milestone Assessment

Next.js Authentication

10 min

Next.js Deployment

10 min

Next.js Internationalization

10 min

Next.js Security

10 min

Next.js Performance

10 min

Recap Quiz

Gated

Milestone Assessment

Progress
0%

0 / 25 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
Next.jsNext.js Tutorial
Lesson

Next.js Internationalization

10 min reading
Free Course

Next.js Internationalization: Multi-Language Routing in app/

Next.js internationalization (i18n) lets you serve localized pages, URLs, and SEO metadata for different languages and regions. In the App Router, you implement localization cleanly using a dynamic [lang] folder segment, JSON dictionaries, and root middleware.

Keeping translation files on the server inside Server Components avoids shipping unused language strings to the visitor's browser.

Structuring [lang] Routes

Wrap your application pages inside an app/[lang]/ folder so URLs automatically include the locale prefix, such as /en/pricing and /es/pricing.

app/
└── [lang]/
    ├── layout.tsx
    ├── page.tsx
    └── pricing/
        └── page.tsx
dictionaries/
├── en.json
└── es.json

Loading Dictionaries in Server Components

Define typed dictionary loaders and await only the dictionary matching the active lang parameter.

{
  "heroTitle": "Build faster web apps",
  "ctaLabel": "Get Started"
}
// app/[lang]/page.tsx
const dictionaries = {
  en: () => import('@/dictionaries/en.json').then((m) => m.default),
  es: () => import('@/dictionaries/es.json').then((m) => m.default),
};

type Locale = keyof typeof dictionaries;

export default async function LocalizedHome({
  params,
}: {
  params: Promise<{ lang: Locale }>;
}) {
  const { lang } = await params;
  const dict = await dictionaries[lang]();

  return (
    <main className="p-8">
      <h2 className="text-3xl font-bold">{dict.heroTitle}</h2>
      <button type="button" className="mt-4 px-4 py-2 bg-blue-600 text-white rounded">
        {dict.ctaLabel}
      </button>
    </main>
  );
}

Redirecting Missing Locales in Middleware

Inspect incoming requests in middleware.ts and redirect root paths without a locale prefix to your default language.

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';

const locales = ['en', 'es'];
const defaultLocale = 'en';

export function middleware(request: NextRequest) {
  const { pathname } = request.nextUrl;
  const hasLocale = locales.some(
    (loc) => pathname === `/${loc}` || pathname.startsWith(`/${loc}/`)
  );

  if (hasLocale) {
    return NextResponse.next();
  }

  request.nextUrl.pathname = `/${defaultLocale}${pathname}`;
  return NextResponse.redirect(request.nextUrl);
}

export const config = {
  matcher: ['/((?!_next|api|favicon.ico).*)'],
};

Common Mistakes

  • Sending every language dictionary to Client Components: Load translations inside Server Components and pass only the needed strings down as props.
  • Hardcoding <html lang="en"> in root layout: Pass the active lang param into app/[lang]/layout.tsx so screen readers and search engines see the right language code.
  • Matching static assets in locale middleware: Exclude _next, api, and image paths in config.matcher so /logo.svg does not redirect to /en/logo.svg.

Frequently Asked Questions

Should I use subpath URLs (/en/about) or domain routing?

Subpath routing is easiest to manage in one App Router deployment and works well with Google search indexing.

How do I pre-build all locales statically?

Export generateStaticParams in app/[lang]/layout.tsx returning [{ lang: 'en' }, { lang: 'es' }].

Can I use next-intl with the Next.js App Router?

Yes, next-intl builds on top of the [lang] pattern and adds pluralization, date formatting, and typed translation hooks.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

Next.js Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format HTML markup
CSS Formatter
Clean and format stylesheets
All Next.js Articles
Deep-dive guides, tips & discussions
PreviousNext.js Deployment
Continue JourneyNext: Next.js Security

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum