Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/smart-pants-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/nextjs": patch
---

Makes the internally used `invalidateCacheAction()` server action an async function to comply with server actions constraints. More information: https://nextjs.org/docs/messages/invalid-use-server-value
2 changes: 1 addition & 1 deletion packages/nextjs/src/app-router/client/ClerkProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const ClientClerkProvider = (props: NextClerkProviderProps) => {
return new Promise(res => {
window.__clerk_internal_invalidateCachePromise = res;
startTransition(() => {
//@ts-expect-error next exitsts on window
//@ts-expect-error next exists on window
if (window.next?.version && typeof window.next.version === 'string' && window.next.version.startsWith('13')) {
router.refresh();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

import { cookies } from 'next/headers';

export function invalidateCacheAction() {
// This function needs to be async as we'd like to support next versions in the range of [14.1.2,14.2.0)
// These versions required 'use server' files to export async methods only. This check was later relaxed
// and the async is no longer required in newer next versions.
// ref: https://github.com/vercel/next.js/pull/62821
export async function invalidateCacheAction() {
return cookies().delete(`__clerk_invalidate_cache_cookie_${Date.now()}`);
}