@teamhanko/passkeys-next-auth-provider
TypeScript icon, indicating that this package has built-in type declarations

0.3.1 • Public • Published

Hanko Passkeys Auth.js Provider

View docs on docs.hanko.io

If you already have a Next.js set up with Auth.js, you can easily passkeys to your app using @teamhanko/passkeys-next-auth-provider.

npm install @teamhanko/passkeys-next-auth-provider

In your pages/api/auth/[...nextauth].ts:

import { tenant, PasskeyProvider } from "@teamhanko/passkeys-next-auth-provider";

export default NextAuth({
	providers: [
		PasskeyProvider({
			tenant: tenant({
				tenantId: "<your tenant id>",
				apiKey: "<your secret api key>",
			}),
			async authorize({ userId }) {
				const user = db.users.find(userId);

				// Do more stuff

				return {
					id: user.id,
					name: user.username,
				};
			},
		}),
	],
});

In one of your components:

import { signInWithPasskey } from "@teamhanko/passkeys-next-auth-provider/client";

export default LoginButton() {
	return (
		<button onClick={() => signInWithPasskey({ tenantId: "<your tenant id>" })} />
	);
}
  1. make sure to pass the baseUrl to both
    tenant (in [...nextauth].ts) and
    signInWithPasskey() (in your component).

  2. get your tenant ID via the admin API

Readme

Keywords

none

Package Sidebar

Install

npm i @teamhanko/passkeys-next-auth-provider

Weekly Downloads

348

Version

0.3.1

License

MIT

Unpacked Size

33.1 kB

Total Files

7

Last publish

Collaborators

  • felixmagedanz
  • bjoern-m
  • lfleischmann
  • freddy_develop
  • felix.dubrownik