-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclerk.ts
29 lines (24 loc) · 805 Bytes
/
clerk.ts
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
import { useEffect } from 'react';
import { useAuth } from '@clerk/nextjs';
function LoadClerkScript() {
const { getToken } = useAuth();
useEffect(() => {
const loadScript = async () => {
const token = await getToken();
const script = document.createElement('script');
script.src = 'https://clerk.datafortress.shop/npm/@clerk/clerk-js@5/dist/clerk.browser.js';
script.async = true;
script.onload = () => {
// Script yüklendiğinde çalışacak kod
};
script.onerror = () => {
console.error('Script yüklenirken hata oluştu.');
};
script.setAttribute('Authorization', `Bearer ${token}`);
document.head.appendChild(script);
};
loadScript();
}, [getToken]);
return null;
}
export default LoadClerkScript;