Skip to content

Implement organization switcher

Let users switch across workspaces using prompt-based selection or direct org routing via organization ID

Organization switching lets users access multiple organizations or workspaces within your application. This guide shows you how to implement organization switching using Scalekit’s built-in switcher or by building your own organization switcher in your application.

This feature is essential for B2B applications where users may belong to several organizations simultaneously. Common scenarios include:

  • Personal workspace to corporate workspace: Users sign up with their organization’s email address, creating their personal workspace. Later, when their organization subscribes to your app, a new corporate workspace is created (for example, “AcmeCorp workspace”).
  • Multi-organization contractors: External consultants or contractors who belong to multiple organizations, each with their own SSO authentication policies. These users need to switch between different client organizations while maintaining secure access to each workspace.

When users belong to multiple organizations, Scalekit automatically handles organization switching during the authentication flow:

  1. Users click Sign In on your application.
  2. Your application redirects users to Scalekit’s sign-in page.
  3. Users authenticate using one of the available sign-in methods.
  4. Scalekit displays a list of organizations that users belong to.
  5. Users select the organization they want to sign in to.
  6. Users are redirected to the organization’s workspace and signed in.

Scalekit provides built-in support for organization switching through automatic organization detection, a hosted organization switcher UI, and secure session management. Each organization maintains its own authentication context and policies.

You can customize the organization switcher’s behavior by adding query parameters when generating the authorization URL. These parameters give you precise control over how users navigate between organizations.

Add the prompt: 'select_account' parameter when generating the authorization URL. This forces Scalekit to display a list of organizations the user belongs to, even if they’re already signed in.

Express.js
// Use case: Show organization switcher after user authentication
const redirectUri = 'http://localhost:3000/api/callback';
const options = {
scopes: ['openid', 'profile', 'email', 'offline_access'],
prompt: 'select_account'
};
const authorizationUrl = scalekit.getAuthorizationUrl(redirectUri, options);
res.redirect(authorizationUrl);

This displays the organization switcher UI where users can choose which organization to access.

Switch users directly to a specific organization

Section titled “Switch users directly to a specific organization”

To bypass the organization switcher and directly authenticate users into a specific organization, include both the prompt: 'select_account' parameter and the organizationId parameter:

Express.js
// Use case: Directly route users to a specific organization
const redirectUri = 'http://localhost:3000/api/callback';
const options = {
scopes: ['openid', 'profile', 'email', 'offline_access'],
prompt: 'select_account',
organizationId: 'org_1233434'
};
const authorizationUrl = scalekit.getAuthorizationUrl(redirectUri, options);
res.redirect(authorizationUrl);

When you include both parameters, Scalekit will:

  • If the user is already authenticated: Directly sign them into the specified organization
  • If the user needs to authenticate: First authenticate the user, then sign them into the specified organization

Use these parameters to control the organization switching behavior:

ParameterDescriptionExample
prompt=select_accountShows the organization switcher UIForces organization selection even for authenticated users
prompt=select_account&organizationId=org_123Direct organization accessBypasses switcher and authenticates directly into the specified organization