I want to solve this problem, but the platform won’t let me answer, which feels very sad. The original question link is as follows How to implement Default Language without URL Prefix in Next.js 14 for Static Export?
I understand this issue and hope it can help you.
Background
- Next.js 14
- static export
- i18n
Just like this, the directory hierarchy is as follows
app
├── [[...lang]]
│ └── page.tsx
└── layout.tsx
In page.tsx, make sure there is a [””]
export async function generateStaticParams() {
const keys = Object.keys(localeNames).map((lang) => ({ lang: [lang] }));
return [{ lang: [""] }, ...keys];
}
// result
[
{ lang: [ '' ] },
{ lang: [ 'en' ] },
{ lang: [ 'zh' ] },
{ lang: [ 'ja' ] },
{ lang: [ 'ar' ] },
{ lang: [ 'es' ] },
{ lang: [ 'ru' ] }
]
next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: { unoptimized: true }
}
module.exports = nextConfig
New contributor
perter_zhu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.