-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
generateStaticParams breaks build when i18n is defined in next.config.js #55331
Comments
I suspect your function was written incorrectly. It should look more like this:
|
See: |
Hey thanks for your response @moonman239, but I think you are confusing getStaticPaths from the Anyway, just to be sure I tried your suggestion. There is actually a syntax error: the right hand side of the arrow function needs to be wrapped in parentheses to return an object rather than interpret that as a function body. So the final code I tried was: export function generateStaticParams() {
const paths = ["en", "es"].map((lang) => ({
params: {
slug: lang,
},
}));
return { paths: paths, fallback: false };
} Which then fails to compile with:
As you can see from the error, it expects an array as the response, not an object. So I do think this is a real bug and not a usage error, but let me know if you have other suggestions. |
Also the SSG works fine when I comment out the |
i18n and /app directory are no longer compatible i had to make a middleware.ts that detects accept lang header to forward them the to the right |
Thank you for the suggestion, yes I am aware that the In our case we have an existing app on pages directory using Ultimately I have found that I need different routing behavior for app versus pages in the middleware, and I have not been able to find a good way to detect which directory the page is served from. Currently I have a proof of concept working by having a hard-coded list of routes that are in the app directory, but it will be easy for that to get out of sync. |
Link to the code that reproduces this issue or a replay of the bug
https://github.com/nickderobertis-ch/app-ssg-i18n-issue
To Reproduce
Current vs. Expected behavior
I expected the build to complete successfully with statically generated pages for each of the values returned in
generateStaticParams
.Instead, the build fails with the following output:
Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 Binaries: Node: 18.7.0 npm: 8.15.0 Yarn: 1.22.19 pnpm: N/A Relevant Packages: next: 13.4.20-canary.26 eslint-config-next: N/A react: 18.2.0 react-dom: 18.2.0 typescript: 5.2.2 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link)
Additional context
I tested my reproduction against different NextJS versions, from 13.0.0 to latest canary 13.4.20-canary.26 (had to remove metadata and make
generateStaticParams
async to go back all the way, that reproduction is on this branch). It seems this bug has existed since the app directory was introduced.This is somewhat related to #53724, at least in that both bugs seem to be related to dynamic routes when
i18n
is defined innext.config.js
. But while that bug was introduced in 13.4.13 and so we can downgrade to avoid it, there is no way to downgrade to avoid this bug.In our case we have an existing NextJS app on the pages directory using
i18n
and we want to incrementally migrate to the app directory and SSG the language pages. This blocks our migration, as we still need to use thei18n
config for the pages directory.The text was updated successfully, but these errors were encountered: