Skip to content

Commit 48da3ac

Browse files
committed
fix(clerk-react): Define global in window if not defined
Vite does not define `global` by default. One workaround is to use the `define` config prop: https://vitejs.dev/config/#define However, we decided to solve this on the SDK level as well to reduce setup steps.
1 parent 3be9cbd commit 48da3ac

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

packages/react/src/index.ts

+10
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ export * from './hooks';
44
export type { ClerkProp } from './types';
55
export { isMagicLinkError, MagicLinkErrorCode } from './errors';
66
export { useMagicLink } from './hooks/useMagicLink';
7+
8+
/**
9+
* Vite does not define `global` by default
10+
* One workaround is to use the `define` config prop
11+
* https://vitejs.dev/config/#define
12+
* We are solving this in the SDK level to reduce setup steps.
13+
*/
14+
if (typeof global === 'undefined' && typeof window !== 'undefined' && !window.global) {
15+
(window as any).global = window;
16+
}

0 commit comments

Comments
 (0)