Installation
Install the SDK using npm or yarn:Quick Start
Initialize the Scalekit client with your environment credentials:utils/auth.js
Core Methods
Generate Authorization URL
Create an authorization URL to redirect users to Scalekit for authentication:Login route
Exchange Authorization Code
Exchange the authorization code for user tokens after the callback:Callback handler
Validate Access Token
Validate access tokens on protected routes:Middleware
Refresh Access Token
Refresh expired access tokens using the refresh token:Token refresh
Organization Management
Create Organization
Create a new organization for enterprise customers:Generate Admin Portal Link
Generate a portal link for customers to configure SSO:Session Management
Get Session Details
Retrieve details for a specific session:List User Sessions
List all active sessions for a user:Revoke Session
Revoke a specific session (logout from one device):Revoke All User Sessions
Revoke all sessions for a user (logout from all devices):Advanced Features
Custom Authorization Options
Customize the authorization flow with additional options:Error Handling
The SDK throws errors that should be caught and handled:TypeScript Support
The SDK includes TypeScript definitions:Framework Examples
Express.js
Complete Express.js integration example:app.js
Next.js
Next.js API route example:pages/api/auth/callback.js