-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
Unexpected behavior when using output: 'export', generateStaticParams(), and export const dynamic #56253
Comments
I confirm. Rolling back to 13.4.19 fixed it. |
@wdavidw I ended up sticking on the latest version but remove the If you have your |
the app was working fine , even with build gives error Error: Page "/[[...slug]]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config. but after removing it now new error appear : invalid next.config.js options detected: while this is the 13.5.2 any suggestion on how to fix it |
For the Python environment, this issue seems to be related. #54393 |
For me, the @Yukigamine solution works, thank you so much! |
Without (Works fine after building and served) |
Downgrading to next 13.4.19 fixed it, but I'm not getting loaded correctly my js and CSS files EDITL I fixed it adding |
That was what initially confused me because But at the very least, the documentation should probably be updated so this situation is avoided or is less confusing. PSA to everyone who downgraded, you can run the latest version of Next.JS, you just need to take out the |
Can i Have more details how to do this ? I feel Like I missed up |
Same problem. Downgrade works for me. |
@bllfoad Have a look at how I update the source code in "page.js" of the TDP Website. |
Search parameters and dynamic paths usually each have different use cases, but in their overlap (ie.
Take a look at @wdavidw's example. Simply omitting or commenting out the lines with |
Same problem. Downgrade works for me. |
What should i do if i want to write code like this export default function StudyMaterialItemPage({params}:{params:{id:string}}) { folder structure: study-materials/[id]/page.tsx in next.config.js: output: 'export' but getting error: Error: Page "/(userPages)/study-materials/[id]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config. |
Best option right now is to downgrade next to 13.4.19. |
The error is telling you exactly what is wrong.
There is no need to downgrade. Simply omitting or commenting out the lines with |
But, how will you have a 404 page when the user enters a route segment that hasn't been generated by |
Your webserver handles that part. When you actually run |
Okay then,where/how can I catch these errors and manually redirect to a custom 404 page? |
If you make a custom not-found using the built-in Next.js features, it will generate a |
Which version did you switch to? |
Yes, same bug when using "export" (v.14.0.3), dynamic route don't work. My system is client side only, so, the "fetch" works after the user sign in, so, I can get the "slug" of the router and fetch the data. Temp solution: downgrade to version 13.4.19 EDIT: I've upgraded to new version again because the "13.4.19" has bugs. So, the solution now is don't use the "dynamic routes", use the "searchParams"... |
I think I'm in same situation as @jadsonlourenco : I'm using export for a pure client-side application, and just trying to use dynamic segments which will fetch data that relies on the segment data. Per @Yukigamine 's comment:
OK, but the docs actually say:
That's exactly what I do not want to do. I don't want to memoize the params, nor pre-compile routes with them at build-time, as these are data-driven params which change constantly. Docs for So... what are we supposed to do differently to support dynamic params with |
I may be wrong, but I don't think you can. The idea of |
In my case, this error was caused by my static parameters function not returning the proper type--typo in the object value. https://nextjs.org/docs/app/api-reference/functions/generate-static-params#returns |
Thanks. You helped me. I had same issue. It was working in dev/build with no export flag. But then failed with explort flag. I was returning a straight array, return ["1","2"] it needs to be in the format: |
can any one tell me why still have this issue in Nextjs 14 , this is my code for user page import axios from 'axios'; export async function generateStaticParams() {
} const Page = async ({ params }) => { User DetailsName: {data.name} Email: {data.email} </> ); }; export default Page; ` |
You should return the params directly, not an object with a |
@karpolan |
this guy has it working with latest next.js. unfortunately I couldn't point to exactly what I was doing different. one thing I noticed was |
It looks like 14 fails if generateStaticParams returns an empty array, in 13 this was accepted. |
I can do this if I am not using server side components, but what if my projetct must be all client side? |
For now, you may be able to work around this by conditionally changing the const nextConfig = {
// Export only when building in GitHub Actions
output: process.env.GITHUB_ACTION ? 'export' : undefined,
}; Then |
Why don't you can just simply remove or comment |
My app doesn't require a backend, and the host I currently use doesn't support one. So I render it as a static site using the If I eventually choose new hosting where NextJS will run as the webserver, then I'll remove |
put this in your page.tsx: export function generateStaticParams() { this will generate routes as: /study-materials/1, /study-materials/2, /study-materials/3 now if you had understood, return Data.map((data) => ({ |
This comment has been minimized.
This comment has been minimized.
I suppose this is the problem of the It's the develop runtime problem(might be a bug of HMR,but I'm not sure), not the problem of developer. |
Code return pageNames.map((pageName) => ({ const validPageNames = ['a', 'b', 'c', 'd', 'e', 'f'] if (!validPageNames.includes(pageName)) { {pageName} Page ) } /** @type {import('next').NextConfig} */ export default nextConfig `` Error : Page "/products/[pageName]/page" is missing param "/products/1" in "generateStaticParams()", which is required with "output: export" config. Issue : When I try to access a non-existent page, it doesn't redirect to the 'Not Found' page. Additionally, after building the project with Next.js, it's not possible to directly access certain pages. If anyone has experienced this issue or knows a solution, I would appreciate your help. Thank you! |
@amartuvshin-bold that's just the error you get instead of a 404 when you're in the dev environment. When you run |
Thanks! That worked for me, I was using Github Codespaces :) |
|
Ran into this just now and I believe I have the same use-case. I'm confused because this feels like a bug to me or at least a missing feature - not missing documentation. i.e. |
Hey @olsonpm, i have the similar issue, where I need to render a page with path I am using standard |
Which combination of I think the reason |
I'm now using a workaround similar to those mentioned above which works fine
but I feel |
Link to the code that reproduces this issue
https://codesandbox.io/p/sandbox/sweet-morning-nl3spx
To Reproduce
output: 'export'
innext.config.js
export const dynamicParams = false
and/orexport const dynamic = 'force-static'
next dev
and attempt to visit a page on the dynamic routeCurrent vs. Expected behavior
Expected behavior:
Ignore the Route Segment Config options and/or generate a warning about them not being compatible.
Actual behavior:
Everything works correctly as long as you don't use output: 'export' and dynamic/dynamicParams together.
When they are, the following error is sent:
Error: Page "/[[...slug]]/page" is missing exported function "generateStaticParams()", which is required with "output: export" config.
The page is obviously not missing the function as it's right there and works fine under different configurations. This error occurs with all three types of Dynamic Routes when the Route Segment Configs are present with
output: export
. (Note: I have only tested withdynamic
anddynamicParams
so far.If you take either of those conditions out, everything works as expected:
output: export
option, it will properly serve 404s when visiting a route that isn't generated.output: export
The errors only actually happen in next dev when both of the aforementioned conditions are present.
This scenario probably just warrants updated documentation and maybe extra sanity checks.
Verify canary release
Provide environment information
Which area(s) are affected? (Select all that apply)
App Router, Routing (next/router, next/navigation, next/link), Static HTML Export (output: "export")
Additional context
During testing, I went back to 13.4.19 and did not receive the error about generateStaticParams() missing under the circumstances described in this big report. I have not yet had a chance to look into whether the error just didn't exist yet or simply wasn't being thrown in that version, but it did entirely ignore the Route Segment Config options.
EDIT: For those looking for a workaround--
Rather than downgrading, simply remove
export const dynamicParams = false
and/orexport const dynamic = 'force-static'
from your file. These lines don't actually do anything inoutput: 'export'
and just causenext dev
to get confused.The text was updated successfully, but these errors were encountered: