Skip to content
Scalekit Docs
Go to Dashboard

Implement organization switcher

Organization switching allows users to access multiple organizations or workspaces within your application. This feature is essential for B2B applications where users may belong to several organizations simultaneously, such as their own company and client organizations they work with.

Common organization switching scenarios include:

  • Personal workspace to corporate workspace: A user signs 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 seamlessly 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 the 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 that 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 the following features:

  • Automatic organization detection: Scalekit identifies all organizations a user belongs to based on their email domain and invitation status
  • Organization switcher UI: Users see a list of available organizations when signing in
  • Secure session management: Each organization maintains its own authentication context and policies

After signing in, you can customize the organization switcher’s behavior by adding query parameters and redirecting users to organization switcher.

These parameters give you precise control over how users navigate between organizations.

To show the organization switcher, users first need to authenticate, then they can access the organization switcher. 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
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 will display 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 organization_id=org_xxxx parameter:

Express.js
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