Overview
This article explains how to switch a user’s organization in an app using the Next.jk SDK with Auth0.
Applies To
- Next.js
- Organizations
Cause
The Next.js SDK does not support this functionality by default.
Solution
Dynamically pass the Organization ID to the authorization parameter in the Auth0 configuration:
export default handleAuth({
login(req, res) {
await handleLogin(req, res, {
authorizationParams: {
organization: String(req.query.organization)
}
});
}
});
Send the user to /api/auth/login?organization=<organization id>
to initiate the login flow using the desired organization.