generateStaticParams() doesn't actually generate static pages?
Unanswered
Brown bear posted this in #help-forum
Brown bearOP
Hi, im trying to create a blog site with Next.JS app router, Prisma, MDX.
When i build & run this, the "static" pages get updated as soon as i update the article, while this is the functionality i want (blog pages rebuild if the db record gets updated), pretty sure this wouldn't happen automatically if they were statically prebuilt.
/article/[id]/page.tsx
Im pretty new to webdev, can you guys share some insights on what might be going on?
P.S I havent got around to building the mdx yet, trying to figure this prebuild issue rn.
When i build & run this, the "static" pages get updated as soon as i update the article, while this is the functionality i want (blog pages rebuild if the db record gets updated), pretty sure this wouldn't happen automatically if they were statically prebuilt.
/article/[id]/page.tsx
import { prisma } from "@/db";
import { notFound } from "next/navigation";
export const dynamicParams = true;
interface PageParams {
id: string;
}
export async function generateStaticParams() {
const posts = await prisma.blogArticle.findMany({
select: {
id: true,
},
where: {
status: "published",
},
});
return posts.map((post) => ({
id: post.id.toString(),
}));
}
export default async function Page({
params,
}: {
params: Promise<PageParams>;
}) {
const postId = parseInt((await params).id);
const post = await prisma.blogArticle.findUnique({
where: { id: postId, status: "published" },
});
if (!post) {
return notFound();
}
return (
<div className="flex flex-col items-left p-8 font-[family-name:var(--font-geist-sans)]">
<main className="flex flex-col items-center sm:items-start">
<h1>{post.title}</h1>
<p>{post.content}</p>
</main>
</div>
);
}
Im pretty new to webdev, can you guys share some insights on what might be going on?
P.S I havent got around to building the mdx yet, trying to figure this prebuild issue rn.
8 Replies
Brown bearOP
Bump 😅
Brown bearOP
chat?
Brown bearOP
i beg you guys i need help
Have you tested this on production?
Like building the app and seeing the production version not the dev version?
Like building the app and seeing the production version not the dev version?
Brown bearOP

Cuvier’s Dwarf Caiman
generateStaticParams works on production mode. (next build command)
Did you refresh your page or disable cache?