npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

next-passkey-webauthn

v0.2.1

Published

Next.js library for Passkey authentication

Readme

Next-Passkey-Webauthn

A focused, minimal, and extensible Passkey (WebAuthn) SDK for Next.js applications.

What is Next-Passkey-Webauthn?

This library provides a complete WebAuthn solution with:

  • Client-side: React hooks that wrap @simplewebauthn/browser
  • Server-side: Utilities that wrap @simplewebauthn/server
  • Persistence: Pluggable adapters for credential storage (Prisma, Supabase)
  • Challenge Storage: Flexible challenge stores (Redis, Database)
  • Type Safety: Full TypeScript support

Installation

npm install next-passkey-webauthn

Quick Start

Choose your preferred setup:

🚀 Setup Guides

  • Supabase + Redis - Recommended for production

    • Supabase PostgreSQL for credential storage
    • Redis for fast challenge storage
    • Scales across multiple nodes
  • Prisma + Redis

    • Prisma ORM with PostgreSQL
    • Redis for challenge storage
    • Full type safety with Prisma
  • Supabase + Database Store

    • All-in-one Supabase solution
    • PostgreSQL for both credentials and challenges
    • Simple deployment
  • Prisma + Database Store

    • Prisma ORM with PostgreSQL
    • Database-backed challenge storage
    • No external dependencies

Architecture Overview

The library follows a clean separation of concerns with three main layers:

Client Side: React hooks that handle user interactions, device detection, and API communication. Hooks like useRegisterPasskey, useAuthenticatePasskey, and useManagePasskeys provide a simple interface for components.

Server Side: WebAuthn handlers that manage the registration and authentication flows. Functions like startRegistration, finishRegistration, startAuthentication, and finishAuthentication handle the core WebAuthn logic and validation.

Storage Layer: Pluggable adapters and stores for data persistence. Adapters (Prisma, Supabase) handle credential storage, while challenge stores (Redis, Database) manage temporary challenge data during WebAuthn flows.

The architecture is designed to be modular - you can mix and match different adapters and stores based on your infrastructure needs.

Key Features

WebAuthn Support

  • Registration: Create new passkeys with device detection
  • Authentication: Secure login with existing passkeys
  • Management: List, delete, and manage user passkeys
  • Multi-device: Support for multiple authenticators per user

Pluggable Architecture

  • Adapters: Switch between Prisma, Supabase, or custom implementations
  • Stores: Choose between Redis, Database, or other challenge storage
  • Configuration: Flexible relying party and security settings

Developer Experience

  • TypeScript First: Complete type safety and IntelliSense
  • React Hooks: Simple, declarative API for components
  • Error Handling: Comprehensive error types and messages
  • Device Detection: Automatic device and browser information

Core Concepts

Flow Types

  • Registration: Creating new passkey credentials
  • Authentication: Using existing passkeys to login

Storage Layers

  • Credential Storage: Persistent storage of passkey data via adapters
  • Challenge Storage: Temporary storage during WebAuthn flows via stores

Security Features

  • Challenge Verification: Prevents replay attacks
  • Origin Validation: Ensures requests come from trusted domains
  • Counter Management: Tracks authenticator usage

API Reference

Server Functions

  • startRegistration() - Begin passkey registration
  • finishRegistration() - Complete passkey registration
  • startAuthentication() - Begin passkey authentication
  • finishAuthentication() - Complete passkey authentication
  • deletePasskey() - Remove a passkey
  • listUserPasskeys() - Get user's passkeys

Client Hooks

  • useRegisterPasskey() - Passkey registration
  • useAuthenticatePasskey() - Passkey authentication
  • useManagePasskeys() - Passkey management

Adapters

  • SupabaseAdapter - Supabase PostgreSQL integration
  • PrismaAdapter - Prisma ORM integration

Challenge Stores

  • RedisStore - Redis-based challenge storage
  • DbStore - Database-based challenge storage
  • SupabaseStore - Supabase-based challenge storage

Examples

Check out the setup guides for complete, working examples:

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.