useOrganization()
The useOrganization composable returns the currently active organization object as a reactive computed ref. It is auto-imported and available everywhere without an explicit import.
Usage
pages/dashboard.vue
<script setup lang="ts">
const organization = useOrganization()
</script>
<template>
<div v-if="organization">
<h1>{{ organization.name }}</h1>
<p>Organization ID: {{ organization.id }}</p>
</div>
<p v-else>No organization selected.</p>
</template>
Return Value
useOrganization() returns a ComputedRef<Organization | null>. The value is null when the user is not signed in or has no active organization.
Organization Object
| Property | Type | Description |
|---|---|---|
id | string | The organization's unique identifier |
name | string | The organization's display name |
ref | string | null | An optional external reference identifier |
Notes
- This composable is re-exported from
@thunderid/vueand behaves identically in Nuxt. - On SSR-rendered pages, the organization value is hydrated from the server session when
preferences.user.fetchOrganizationsis enabled. - To switch organizations, use the
<ThunderIDOrganizationSwitcher />component or call the/api/auth/organizations/switchroute directly.