markjaquith / clerk-sveltekit

Clerk adapter for SvelteKit
Other
146 stars 21 forks source link

Reactivily using window.Clerk client-side #58

Open svjaime opened 4 months ago

svjaime commented 4 months ago

How can I achieve reactivity with window.Clerk ?

e.g.: I expected that $: console.log(window.Clerk?.organization) to log everytime the user changes organization in the UI, but that doesn't happen. Is there any other way to access clerk's data?

wobsoriano commented 2 months ago

Wait for this PR to be merged, and you will be able to do it like this:

<script lang="ts">
    import { useClerkContext } from 'clerk-sveltekit/client'

        const { clerk, organization } = useClerkContext()

    $: console.log($clerk?.organization)
        $: console.log($organization)
</script>