I feel like I must be missing something or misunderstand something.
I am using generateStaticParams
:
export async function generateStaticParams() {
let blogPosts = await prisma.posts.findMany({
where: {
category: "POLITICS",
},
});
const paths = blogPosts.map((text) => ({
slug: text.slug,
}));
return paths
}
I want to only generate static pages only for this route, and return a 404
when a user tries to visit something, that does not exist at build time. So I am opting out of dynamic:
export default MyPage;
export const dynamic = 'force-static'
export const dynamicParams = false;
However, when I build this, this gives me a 404
for all my static routes. It works when I leave things dynamic and also in development, but not when I build the project.
Next.JS also tells me that it recgonised the page and generated a static version:
├ ● /posts/[slug] 0 B 0 B
├ └ /posts/my-static-post
├ ○ /about 0 B 0 B
But when I visit it in production, it's a 404
.
Removed the 'use client' does work for me.
Thanks to @Kevin Kirsten Lucas for their comment that mentioned it.