Hanko Elements Frontend SDK Guide:About Hanko:Hanko is a modern open source authentication solution and the fastest way you integrate passkeys, 2FA, SSO, and more—with full control over your data. Move between self-hosted and Hanko Cloud anytime. No lock-in. Just Auth how it should be: secure, user friendly, and fully yours.What This Guide Covers: This guide demonstrates how to use the Hanko Frontend SDK directly for advanced authentication workflows and custom implementations. You’ll learn to handle authentication events, manage user sessions, and perform common operations without relying solely on web components.Key Technologies:
You can create a - Hanko Frontend SDK
- JavaScript/TypeScript
- Authentication events
- Session management
- JWT handling
- User management
- Custom authentication flows
- Basic knowledge of JavaScript/TypeScript, authentication concepts, event handling, and Hanko Elements setup
- Understanding of JWT tokens and session management will be helpful
- Create and configure a Hanko Frontend SDK instance
- Implement event listeners for authentication state changes
- Handle session creation, expiration, and user logout events
- Perform common operations like session validation and user data retrieval
- Manage authentication tokens and user sessions
- Build custom authentication flows using the SDK methods
hanko-frontend-sdk
instance without registering the web components:
Events
You can bind callbacks to different custom events using the SDK’s event listener functions. The callback function will be called when the event occurs, and an object containing event details will be passed to it.Session created
Triggered after a session has been created and the user has completed any additional steps (e.g., passkey registration or password recovery). It will also be triggered when the user logs in via another browser window. You can use this event to obtain the JWT.Session expired
Triggered when the session has expired, or when the session has been removed in another browser window because the user has logged out or deleted their account.User logged out
Triggered when the user actively logs out. In other browser windows, a “hanko-session-expired” event will be triggered at the same time.User deleted
Triggered when the user has deleted their account. In other browser windows, ahanko-session-expired
event will be triggered at the same time.