Skip to Content

Overview

Providers in AuthKit define how users authenticate.
They encapsulate the logic for login, registration, and session hydration.


What is a Provider?

A provider implements the logic for authenticating a user — whether it’s with email/password, passkey, OAuth, or even a custom strategy (like magic links).

Each provider must implement the following interface:

export type AuthorizeTypes = "oauth" | "email" | "credentials" | "passkey"; export interface Provider { name: string; type: AuthorizeTypes; config?: Record<string, any>; authorize: (body: Body) => Promise<AdapterUser | null>; register?: (body: Body) => Promise<AdapterUser | void | null>; callback?: (req: NextRequest) => Promise<AdapterUser | null>; }

Registering Providers

To use a provider, register it in your AuthKit() setup:

import { AuthKit } from "@astra-void/auth-kit"; import { CredentialProvider, PasskeyProvider } from "@astra-void/auth-kit/providers"; import { PrismaAdapter } from "@astra-void/auth-kit/adapters"; export const handler = AuthKit({ adapter: PrismaAdapter(prisma), providers: [ CredentialProvider(), PasskeyProvider({ ... }) ] });

You can register multiple providers. Each one will be mapped to the login("provider-name", ...) or register("provider-name", ...) on the client.

Built-in Providers

Credential

Traditional email + password authentication.

import { AuthKit } from "@astra-void/auth-kit"; import { CredentialProvider } from "@astra-void/auth-kit/providers"; import { PrismaAdapter } from "@astra-void/auth-kit/adapters"; export const handler = AuthKit({ adapter: PrismaAdapter(prisma), providers: [ CredentialProvider(), ] });
  • You may use argon2, bcrypt, or other hashers.

  • Simple and widely compatible.

  • No extra config required.

Passkey

WebAuthn-based passwordless login using biometrics or device-based authentication.

  • Requires a challengeStore (e.g. Redis)

  • Supports both “email-first” and “credential-only” modes

See Passkey Overview for full details.

Custom Provider Example

You can define your own provider easily:

import { Provider } from "@astra-void/auth-kit/providers"; const MagicLinkProvider: Provider = { name: "magiclink", type: "email", authorize: async ({ token }) => { const user = await getUserFromToken(token); return user ?? null; }, register: async ({ email }) => { return await createUser({ email }); } };

Notes

  • Providers are independent — each handles only its own logic.

  • You can mix and match multiple strategies per app.

  • The client API (login, register) chooses the provider by name.

See Also

Last updated on