Prerequisites
Describe the issue
Whenever I want to protect my route by checking particular permissions by my server side helper function:
export async function canViewProtected() {
const { getPermission } = getKindeServerSession();
return !!(await getPermission(KINDE_PERMISSIONS.VIEW_PROTECTED))?.isGranted;
}
and by running it at the route settings/page.tsx like this:
export default async function AppSettingsPage() {
if (!(await canViewProtected())) {
redirect('/');
}
// rest of the code
}
it results in following error at the build time:
Error: Dynamic server usage: Route /settings couldn't be rendered statically because it used `cookies`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error
at m (.next/server/chunks/719.js:12:41210)
at p (.next/server/chunks/668.js:1:349523)
at <unknown> (.next/server/chunks/668.js:1:302789)
at d (.next/server/chunks/668.js:1:290669)
at o.value (.next/server/chunks/668.js:1:290447)
at Generator.next (.next/server/chunks/668.js:1:291075)
at lv (.next/server/chunks/668.js:1:295893)
at a (.next/server/chunks/668.js:1:296096)
at <unknown> (.next/server/chunks/668.js:1:296157)
at new Promise (<anonymous>) {
description: "Route /settings couldn't be rendered statically because it used `cookies`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error",
digest: 'DYNAMIC_SERVER_USAGE'
}
error is the same like in #310 issue, but seems like the trigger is different. Again it complains about usage of the cookies at the server component causing that it cannot be rendered statically.
Library URL
kinde-oss/kinde-auth-nextjs
Library version
2.5.3
Operating system(s)
macOS
Operating system version(s)
Sequoia 15.3.1
Further environment details
node v22
next v15
Reproducible test case URL
No response
Additional information
No response
Prerequisites
Describe the issue
Whenever I want to protect my route by checking particular permissions by my server side helper function:
and by running it at the route
settings/page.tsxlike this:it results in following error at the build time:
error is the same like in #310 issue, but seems like the trigger is different. Again it complains about usage of the cookies at the server component causing that it cannot be rendered statically.
Library URL
kinde-oss/kinde-auth-nextjs
Library version
2.5.3
Operating system(s)
macOS
Operating system version(s)
Sequoia 15.3.1
Further environment details
node v22
next v15
Reproducible test case URL
No response
Additional information
No response