-
Notifications
You must be signed in to change notification settings - Fork 452
Expand file tree
/
Copy pathDynamicClerkScripts.tsx
More file actions
42 lines (36 loc) · 1.1 KB
/
DynamicClerkScripts.tsx
File metadata and controls
42 lines (36 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from 'react';
import { ClerkScriptTags } from '../../utils/clerk-script-tags';
import { getNonce } from './utils';
type DynamicClerkScriptsProps = {
publishableKey: string;
clerkJSUrl?: string;
clerkJSVersion?: string;
clerkUIUrl?: string;
domain?: string;
proxyUrl?: string;
prefetchUI?: boolean;
};
/**
* Server component that fetches nonce from headers and renders Clerk scripts.
* This component should be wrapped in a Suspense boundary to isolate the dynamic
* nonce fetching from the rest of the page, allowing static rendering/PPR to work.
*/
export async function DynamicClerkScripts(props: DynamicClerkScriptsProps) {
const { publishableKey, clerkJSUrl, clerkJSVersion, clerkUIUrl, domain, proxyUrl, prefetchUI } = props;
if (!publishableKey) {
return null;
}
const nonce = await getNonce();
return (
<ClerkScriptTags
publishableKey={publishableKey}
clerkJSUrl={clerkJSUrl}
clerkJSVersion={clerkJSVersion}
clerkUIUrl={clerkUIUrl}
nonce={nonce}
domain={domain}
proxyUrl={proxyUrl}
prefetchUI={prefetchUI}
/>
);
}