-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
initializeClerkClient
should be awaited
#46
Comments
initializeClerkClient
should be awaited
Having a top-level await can be tricky and not supported in older environments. How to account for those that can't support that? Upon testing - if we block the thread here it may never resolve. I think this is the right place to start initializing Clerk, but I don't think the promise can ever finish until after it renders the page DOM. Blocking here may break the load. |
I mean I'm just stating the problem, not sure what the best solution would be. But I guess you can detect if the env is old/doesn't support await, e.g.:
and use
|
When this PR gets merged, the <script lang="ts">
import { useClerkContext } from 'clerk-sveltekit/client'
const { user, session, organization, clerk, client } = useClerkContext()
$: {
console.log('user', $user)
console.log('session', $session)
console.log('organization', $organization)
console.log('clerk', $clerk)
console.log('client', $client)
}
</script> |
initializeClerkClient
returns aPromise
. So, shouldn't it be awaited? If so, you should fix both your documentation & examples.I noticed that without it, if I try to use
window.Clerk
inside a component's<script />
it errors becausewindow.Clerk
is undefined (yet). After addingawait
oninitializeClerkClient
it works.The text was updated successfully, but these errors were encountered: