next-intl-setRequestLocale-ssg-fix

Call setRequestLocale before getMessages in Next.js server components for SSG.

Updated Mar 4, 2026
One-click install
npx skills add https://github.com/hubeiqiao/skills --skill next-intl-setrequestlocale-ssg-fix
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: next-intl-setRequestLocale-ssg-fix
Source: https://github.com/hubeiqiao/skills/tree/main/next-intl-setRequestLocale-ssg-fix
Command: npx skills add https://github.com/hubeiqiao/skills --skill next-intl-setrequestlocale-ssg-fix

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill resolves an issue where static-generated pages in Next.js using next-intl v4+ incorrectly display the default locale instead of the intended one at runtime.

Core Features & Use Cases

  • SSG Locale Correction: Ensures correct locale rendering for statically generated pages.
  • Server Component Fix: Addresses the root cause by correctly setting the locale context in server components.
  • Use Case: When your Next.js app builds pages for multiple languages using generateStaticParams but all pages show English content, this skill provides the necessary fix.

Quick Start

Apply the setRequestLocale function before getMessages in your server components.

Frequently Asked Questions about next-intl-setRequestLocale-ssg-fix

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix next-intl SSG pages rendering the wrong locale at runtime?

Incorrect SSG locale rendering happens when getMessages runs before the static context has a defined locale. You fix this by calling setRequestLocale before getMessages in your Next.js server components to enforce the correct language context.

How do I use setRequestLocale with generateStaticParams in next-intl?

To use setRequestLocale with generateStaticParams, call the function at the start of your server component layout before fetching messages. This ensures the static generation build correctly locks the requested locale context for each generated page.

Does next-intl v4 require explicit locale setting for static site generation?

Yes, next-intl v4 requires explicit locale setting for static site generation. Server components must call setRequestLocale to establish the rendering context, otherwise SSG pages will default to English despite generating correct build output.

Why are all my next-intl static pages defaulting to English despite a successful multi-language build?

Static pages default to English when the locale context is missing during server component rendering. Applying setRequestLocale before retrieving messages resolves this by explicitly binding the intended locale to the static generation request lifecycle.

What are the limitations of using setRequestLocale for static generation in Next.js?

The limitation of setRequestLocale for static generation is that it must strictly precede getMessages in server components. If called out of order or omitted, the static rendering context fails to apply the intended locale, reverting pages to the default language.