Issue using dynamic routes with static export (App Router)
Unanswered
Milkfish posted this in #help-forum
MilkfishOP
I'm trying to use dynamic routes to display products in my application, but I'm getting an error when accessing a dynamic route that is not generated with generateStaticParams(). The routes look like
I'm getting this error when trying to access a page that should return a 404:
After researching this issue I found that some suggesting setting the dynamicParams value to false, but it seems like this does nothing when static output is enabled. Does anyone know how to get this to work with static output?
Here's the code for my /products/[id]/page.tsx:
/products/[id]. I currently have the app deployed on cloudflare which requires static outputs so we have output: "export" in our next.config.js. I'm getting this error when trying to access a page that should return a 404:
Error: Page "/products/[id]/page" is missing param "/products/product-that-isnt-in-our-data" in "generateStaticParams()", which is required with "output: export" config. After researching this issue I found that some suggesting setting the dynamicParams value to false, but it seems like this does nothing when static output is enabled. Does anyone know how to get this to work with static output?
Here's the code for my /products/[id]/page.tsx:
export async function generateStaticParams() {
return PRODUCTS.map((product) => ({
id: product.id,
}))
}
export default function ProductPage({ params }: { params: { id: string } }) {
const { id } = params
return (
<>
<Product id={id}/>
</>
)
}1 Reply
Asiatic Lion
I'm facing the same problem, did you get a solution for that? I'll probably have to refactor a lot of code if there's none...