Hanko Elements
Hanko Elements provide web components that add a modern login and registration experience for your users.
Web Components
<hanko-login/>
A web component that handles user login.
<hanko-register/>
A web component that handles user registration.
<hanko-auth/>
A web component that handles user login and registration.
<hanko-profile/>
Allows Users to manage their login methods.
Features
Web Components
Pre-built components to give you fully-functional authentication and user management in minutes.
Customization
Fully customize web components to match your style preferences.
Internationalization
Supports multiple languages and provides translation options for a global user base.
Integration Flexibility
Offers versatile choices for integration, including CDN or npm.
Installation
Integrate Hanko Elements into your project using your preferred package manager or CDN implementation:
Usage
To implement Hanko, import and invoke the register()
function from the hanko-elements
module. This enables the use of web components throughout your application.
For proper functionality, implement the <hanko-auth />
element to enable user authentication, and configure the “onSessionCreated” event handler to specify
post-authentication behavior, such as page redirection. Detailed implementation steps are provided in subsequent sections.
Importing the module
If installed through a package manager, you can import the register()
function from the @teamhanko/hanko-elements
package in your TypeScript or JavaScript file
For CDN implementation, include a script
tag with the import statement referencing the CDN-hosted hanko-elements
package URL.
Registering the Web Components
After importing the register()
function, call it with your Hanko API URL as an argument to register the Hanko elements with the browser’s CustomElementRegistry
.
Configuration options can be provided to customize the behavior and appearance of the components.
Cookie options
- If
cookieSameSite
is set tonone
then your application must be served through HTTPS. TheSecure
attribute is automatically set to true if your application uses HTTPS. - If you want cookies to be available on subdomains, you must set your
cookieDomain
to your domain prefixed with a.
. For example, if your frontend application is running onmyapp.com
and you want cookies to be available onapi.myapp.com
, then thecookieDomain
value should be.myapp.com
.
Embedding the Web Components
After implementing the above steps, you can incorporate the web components into your application’s markup. Here’s a basic implementation example: