nuxt-x-tenancy
Components
XTTenantSwitcher and XTTenantResolver — the XT* tenant UI components of nuxt-x-tenancy.
Components
Two auto-imported XT* components (folder app/components/X/T/). Both consume useTenant() internally and need no wiring.
XTTenantSwitcher
A USelectMenu of tenants; selecting one calls switchTenant(), which sets the active organization and flushes the old tenant's useXCrud cache scope.
<template>
<XTTenantSwitcher placeholder="Select organization" />
</template>
| Prop | Type | Default | Description |
|---|---|---|---|
placeholder | string | — | Placeholder text when no tenant is active. |
hideWhenSingle | boolean | false | Render nothing when the user belongs to only one tenant. |
XTTenantResolver
A gate for tenant-scoped content with three slots:
<template>
<XTTenantResolver>
<template #loading>
<USkeleton class="h-8 w-full" />
</template>
<template #default="{ tenant }">
<p>Active tenant: {{ tenant.name }}</p>
</template>
<template #empty>
<p>Select an organization to continue.</p>
</template>
</XTTenantResolver>
</template>
| Slot | Scope | Shown when |
|---|---|---|
loading | — | isResolving is true (switching/resolving or org data loading). |
default | { tenant: Tenant } | A tenant is active. |
empty | — | Resolution finished with no active tenant. |
AI Context
components: [XTTenantSwitcher, XTTenantResolver]
package: "@xenterprises/nuxt-x-tenancy"
use-when: >
Tenant UI: XTTenantSwitcher renders a tenant picker that calls
switchTenant on select; XTTenantResolver gates tenant-scoped content
with loading/default(scoped tenant)/empty slots.
Resolution chain
How nuxt-x-tenancy resolves the active tenant — path, subdomain, and header strategies, middleware ordering, and the upstream better-auth slug-lookup caveat.
Backend requirements
What the backend must provide for nuxt-x-tenancy — the better-auth organization endpoints, the tenant id contract, and the X-Tenant-ID data-API contract.
