Skip to main content

Install @teamhanko/hanko-elements

Install hanko-elements to access the pre-built hanko-auth and hanko-profile components.

Add the Hanko API URL

Retrieve the API URL from the Hanko Console and place it in your .env file.
.env
If you are self-hosting you need to provide the URL of your running Hanko backend.

Add <hanko-auth> component

Add the <hanko-auth> web component to create a login interface. Import the register function from @teamhanko/hanko-elements and call it with your Hanko API URL to register the component with the browser’s CustomElementRegistry.
components/HankoAuth.tsx
By now, your sign-up and sign-in features should be working. You should see an interface similar to this 👇
sign up

Add <hanko-profile> component

The <hanko-profile> component provides an interface, where users can manage their email addresses and passkeys.
components/HankoProfile.tsx
It should look like this 👇
profile page

Implement logout functionality

Create a logout button component using @teamhanko/hanko-elements to manage user logouts:
components/LogoutButton.tsx

Customize component styles

You can customize the appearance of hanko-auth and hanko-profile components using CSS variables and parts. Refer to our customization guide.

Authenticate backend requests

To authenticate requests on your backend with Hanko, refer to our backend guide.

Try it yourself

Solid.js example

It uses Express.js for the backend, full source code available on our GitHub.