The @teamhanko/passkeys-sdk package lets you call the Hanko Passkey API from JavaScript/TypeScript that supports fetch.

This includes Node.js, Browsers, Deno, Bun, and frameworks like Next.js, Astro, and SvelteKit.

npm i @teamhanko/passkeys-sdk

Usage

A tenant is an API client instance for one tenant of the Hanko Passkey API.

If you use Hanko Cloud, get your tenant ID and API key from the dashboard.

Create a new tenant instance:

const passkeyApi = tenant({
  tenantId: "<your tenant id>",
  apiKey: "<your secret api key>",
});
  • If you only use public API methods, like /login/initialize, you can omit the apiKey.
  • If you’re self-hosting the Passkey API, make sure to pass the baseUrl as well.

Now you’re ready to call the API. For example, to start the process of registering a new passkey:

const creationOptions = await tenant.registration.initialize({
  userId: "<id of the user in your database>",
  username: "<username of the user>",
});

Example Implementation

Check out sample apps made using the SDK: