Set Active Organization by Slug
- Category
- SDK
- Published
It is now possible to set an active organization by URL slug, making it easier to use the URL as the source of truth for the active organization.
For applications that include the organization slug in their URL path, when managing the Clerk active organization, it is common to have an organization slug handy from the URL, but not necessarily an organization ID.
Now, it's possible to call setActive
with an organization slug. This saves an extra call to fetch the organization ID, improving performance and reducing complexity.
The example below creates a component that uses The Next.js useParams() hook to get the organization slug from the URL, and then the setActive
method to set that organization as active.