<RequireActiveTenancy/> component

<RequireActiveTenancy /> is the tenancy gate for apps that are organized around organizations and workspaces. It keeps scoped UI out of the way until the current session has a valid place to land.

Usage

The following example shows a basic usage of <RequireActiveTenancy />.

import { RequireActiveTenancy } from '@wacht/nextjs';export default function RequireActiveTenancyUsage() {  return (    <>      <RequireActiveTenancy>        {children}      </RequireActiveTenancy>    </>  );}

What it guards

The component waits for tenancy state to load, then checks the active organization and, when workspaces are enabled, the active workspace that belongs to that organization.
If the scope is valid it renders its children. If not, it opens the organization selector so the user can fix the scope before the app continues.

How it decides

The gate reads useActiveTenancy() under the hood. That hook combines the session, organization memberships, and workspace memberships into one tenancy check.
If the current organization or workspace is restricted, missing, or out of sync with the active session, the gate stays closed and shows the selector flow instead.
  • When workspaces are disabled, an organization is enough.
  • When workspaces are enabled, both the organization and workspace have to line up.
  • The gate does not create a new tenancy; it only asks the user to pick a valid one.

When to use it

Use it around the main shell of an app that needs tenancy context before rendering anything useful. It keeps downstream pages from having to repeat the same scope check.
It is especially useful when the app contains organization settings, workspace settings, or data that should never show up against the wrong tenant.

On this page