How do I get the currently active organization?
I see there's SignedIn let:user. Is there something equivalent to get the currently active organization? Callbacks? Events? Exposed variables?
I encountered the same situation right now: you should be able to receive the active organization through window.Clerk?.organization
I encountered the same situation right now: you should be able to receive the active organization through
window.Clerk?.organization
but how do I notice the organization changed? I need an event or reactive property...
This might help you:
function handleClerkChange(event) {
const user: UserResource = event.detail;
// do stuff
}
onMount(() => {
document.addEventListener('clerk-sveltekit:user', handleClerkChange);
return () => {
document.removeEventListener('clerk-sveltekit:user', handleClerkChange);
};
});
This PR in review but here's how to do it if it gets merged:
<script lang="ts">
import { useClerkContext } from 'clerk-sveltekit/client'
const { organization } = useClerkContext()
$: console.log($organization)
</script>
This might help you:
function handleClerkChange(event) { const user: UserResource = event.detail; // do stuff } onMount(() => { document.addEventListener('clerk-sveltekit:user', handleClerkChange); return () => { document.removeEventListener('clerk-sveltekit:user', handleClerkChange); }; });
gets current user object, but not organization