Skip to content

Commit ca2f4dd

Browse files
committed
fix(clerk-sdk-node): Support Clerk instantiation with the new keyword
Clerk needs to be a *named* function in order to support the older new Clerk() syntax for v4 compatibility. Arrow functions can never be called with the new keyword because they do not have the [[Construct]] method.
1 parent 706b154 commit ca2f4dd

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

‎packages/sdk-node/src/clerkClient.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ export const API_VERSION = process.env.CLERK_API_VERSION || 'v1';
88
export const API_KEY = process.env.CLERK_SECRET_KEY || process.env.CLERK_API_KEY || '';
99
export const PUBLISHABLE_KEY = process.env.CLERK_PUBLISHABLE_KEY || '';
1010

11-
export const Clerk = (options: ClerkOptions) => {
11+
/**
12+
* This needs to be a *named* function in order to support the older
13+
* new Clerk() syntax for v4 compatibility.
14+
* Arrow functions can never be called with the new keyword because they do not have the [[Construct]] method
15+
*/
16+
export function Clerk(options: ClerkOptions) {
1217
const clerkClient = _Clerk(options);
1318
const expressWithAuth = createClerkExpressWithAuth({ ...options, clerkClient });
1419
const expressRequireAuth = createClerkExpressRequireAuth({ ...options, clerkClient });
1520
return { ...clerkClient, expressWithAuth, expressRequireAuth };
16-
};
21+
}
1722

1823
export const createClerkClient = Clerk;
1924

‎packages/sdk-node/src/instance.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Clerk } from '@clerk/backend';
1+
import { Clerk } from './clerkClient';
22

33
export default Clerk;
44

0 commit comments

Comments
 (0)