From 8c01a6f89e59991ef4f96dfd194d15bf30514310 Mon Sep 17 00:00:00 2001 From: Dimitris Klouvas Date: Sat, 30 Sep 2023 01:43:28 +0300 Subject: [PATCH] fix(shared): Fix error improrting @clerk/shared in RSC SDK (eg @clerk/nextjs) node_modules/@clerk/shared/dist/cjs/hooks/createContextAndHook.js (43:35) @ createContext createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component at createContextAndHook (webpack-internal:///(rsc)/./node_modules/ @clerk/shared/dist/cjs/hooks/createContextAndHook.js:48:38) at eval (webpack-internal:///(rsc)/./node_modules/@clerk/shared/ dist/cjs/hooks/contexts.js:53:110) --- packages/shared/src/hooks/contexts.tsx | 2 ++ packages/shared/src/hooks/createContextAndHook.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/shared/src/hooks/contexts.tsx b/packages/shared/src/hooks/contexts.tsx index 8c18e278b08..d70c53f3e0f 100644 --- a/packages/shared/src/hooks/contexts.tsx +++ b/packages/shared/src/hooks/contexts.tsx @@ -1,3 +1,5 @@ +'use client'; + import type { ActiveSessionResource, ClientResource, diff --git a/packages/shared/src/hooks/createContextAndHook.ts b/packages/shared/src/hooks/createContextAndHook.ts index b7df23501fc..3f3de595246 100644 --- a/packages/shared/src/hooks/createContextAndHook.ts +++ b/packages/shared/src/hooks/createContextAndHook.ts @@ -1,3 +1,4 @@ +'use client'; import React from 'react'; export function assertContextExists(contextVal: unknown, msgOrCtx: string | React.Context): asserts contextVal {