Clerk logo

Clerk Docs

Ctrl + K
Go to

Organization Switching

Learn how to switch the active organization and how it impacts the JWT


Within the Clerk organization feature, there is a concept of an active organization. The active organization is the current organization that will be returned by the useOrganization() hook or by Clerk.organization.

The organization attributes are updated automatically and will re-render their respective components whenever you set a different active organization using the setActive({ organization }) method or update any of the memberships or invitations. There is no need to manage the organization updating manually.

Active organization in JWT

Clerk stores the active organization identifier in the session token under the org_id property. The org_role property will also reflect the user's current role within the active organization. By storing these claims in the JWT, these values can be accessed without making a network call.

Determine the active organization from the backend

Having enabled the Organizations feature, session tokens generated by Clerk contain the additional claims org_id, org_role and orgs which can be used on the server or edge side of your application.

These claims area accessible through the path, where all the Clerk token claims reside.

In the same manner you can protect organization pages for administrators securely on the server-side and also fetch any kind of data needed for server-side rendering.


Example implementation in Next.js of an organization switcher:


Was this helpful?

Clerk © 2022