mattz
mattz
TTCTheo's Typesafe Cult
Created by mattz on 1/7/2024 in #questions
ssg with app router
When using ssg with the new t3-stack app router, i'm getting this:
[cause]: n [Error]: Dynamic server usage: Page couldn't be rendered statically because it used cookies. See more info here: https://nextjs.org/docs/messages/dynamic-server-error It doens't prevent build, but i recieve this error for every page render as SSG.
export async function generateStaticParams() {
const resultsIds = await db.diagnosticResult.findMany({
select: {
id: true,
},
});

return resultsIds.map(({ id }) => ({
id: id,
}));
}

export default async function page({ params }: { params: { id: string } }) {
const result = await api.diagnosticResult.findById.query(params.id);

if (!result) notFound();

return (
<main className="p-6">
<DiagnosticResult result={result} />
</main>
);
}
export async function generateStaticParams() {
const resultsIds = await db.diagnosticResult.findMany({
select: {
id: true,
},
});

return resultsIds.map(({ id }) => ({
id: id,
}));
}

export default async function page({ params }: { params: { id: string } }) {
const result = await api.diagnosticResult.findById.query(params.id);

if (!result) notFound();

return (
<main className="p-6">
<DiagnosticResult result={result} />
</main>
);
}
38 replies