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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@prefabs.tech/fastify-phone-auth

v0.96.0

Published

Fastify phone auth plugin

Downloads

430

Readme

@prefabs.tech/fastify-phone-auth

A Fastify plugin that adds phone/SMS OTP passwordless login to an API built on @prefabs.tech/fastify-user, backed by the Twilio Verify API.

Why this plugin?

SuperTokens ships a Passwordless recipe, but wiring it to Twilio Verify and to your own users table is a surprising amount of work — SuperTokens wants to own the OTP, Twilio Verify wants to own the OTP, and neither knows about your database. This plugin exists to:

  • Bridge SuperTokens and Twilio Verify: Twilio Verify generates, delivers and checks the real OTP; SuperTokens is handed a placeholder code so its own flow still completes. All of that is hidden behind one plugin registration.
  • Keep the auth package lean: passwordless is opt-in. Apps that do not use it never install twilio, and @prefabs.tech/fastify-user carries no passwordless config surface.
  • Initialise the recipe automatically: registering this plugin is all it takes — the SuperTokens Passwordless recipe is contributed to @prefabs.tech/fastify-user's recipe list for you.
  • Create the local user row: on first sign-in a matching row is created in your users table with the phone number and a synthetic <phoneNumber>@<fallbackEmailDomain> email, since SuperTokens requires an email.
  • Own the phone_number column: an idempotent migration adds it to the users table, the User type from @prefabs.tech/fastify-user is augmented with phoneNumber?: string, and the GraphQL User type is extended at runtime — no wiring on your side.
  • Support local development without Twilio: a dev mode and a per-number bypass list accept a fixed OTP so you can develop and test without sending real SMS.

Requirements

Peer dependencies (install compatible versions — see package.json):

Installation

Install with npm:

npm install @prefabs.tech/fastify-config @prefabs.tech/fastify-error-handler @prefabs.tech/fastify-slonik @prefabs.tech/fastify-user @prefabs.tech/fastify-phone-auth fastify fastify-plugin slonik supertokens-node

Install with pnpm:

pnpm add --filter "@scope/project" @prefabs.tech/fastify-config @prefabs.tech/fastify-error-handler @prefabs.tech/fastify-slonik @prefabs.tech/fastify-user @prefabs.tech/fastify-phone-auth fastify fastify-plugin slonik supertokens-node

Usage

Register the plugin — before @prefabs.tech/fastify-user

SuperTokens allows exactly one global init(), and @prefabs.tech/fastify-user performs it while it is being registered. This plugin therefore has to be registered first, so its recipe is in the list by the time that happens.

import configPlugin from "@prefabs.tech/fastify-config";
import phoneAuthPlugin from "@prefabs.tech/fastify-phone-auth";
import slonikPlugin from "@prefabs.tech/fastify-slonik";
import userPlugin from "@prefabs.tech/fastify-user";
import Fastify from "fastify";

const fastify = Fastify();

await fastify.register(configPlugin, { config });
await fastify.register(slonikPlugin);
await fastify.register(phoneAuthPlugin); // contributes the recipe
await fastify.register(userPlugin); // runs supertokens.init()

Registering it after @prefabs.tech/fastify-user throws:

SuperTokens is already initialised. Register SuperTokens recipe plugins before @prefabs.tech/fastify-user.

Configuration

const config: ApiConfig = {
  // ...
  phoneAuth: {
    fallbackEmailDomain: "example.com",
    twilio: {
      accountSid: process.env.TWILIO_ACCOUNT_SID,
      authToken: process.env.TWILIO_AUTH_TOKEN,
      verifyServiceSid: process.env.TWILIO_VERIFY_SERVICE_SID,
    },
  },
};

For local development, skip Twilio entirely:

phoneAuth: {
  devModeOtp: "123456",
  enableDevMode: true,
  fallbackEmailDomain: "example.com",
}

See the developer guide for the full configuration reference, the SuperTokens endpoints this exposes, and the override hooks.