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

expo-otp-autofill-consent

v0.1.5

Published

A native Expo module for Android that enables easy OTP autofill using the SMS User Consent API. It requires no special SMS formatting or app hashes, providing a seamless one-tap verification experience.

Readme

expo-otp-autofill-consent Android Only

A native Expo module for Android that enables easy OTP autofill using the SMS User Consent API.

[!IMPORTANT] This module is designed specifically for Android. On iOS, native OTP autofill is handled automatically by the system keyboard when using textContentType="oneTimeCode".

Features

  • One-Tap Consent: Triggers the standard Android system dialog to read the SMS.
  • No Permissions Needed: Uses Google Play Services, so you don't need to ask the user for READ_SMS permissions.
  • Easy Integration: Simple event-based API for both capturing the OTP and handling timeouts.
  • [x] Expo Managed/Development Builds: Compatible with Expo SDK 54+ (managed and development builds).

Preview

Installation

npx expo install expo-otp-autofill-consent

Usage

This example shows how to use the module with React Hook Form and a ref to automatically set the OTP value. It works for both TypeScript and JavaScript.

import React, { useEffect, useRef } from 'react';
import { useForm } from 'react-hook-form';
import { 
  startSmsUserConsent, 
  addSmsListener, 
  removeSmsListener 
} from 'expo-otp-autofill-consent';

export default function OtpScreen() {
  const { setValue } = useForm();
  const otpInputRef = useRef(null);

  useEffect(() => {
    // 1. Start listening for SMS
    startSmsUserConsent();

    // 2. Listen for SMS and auto-extract OTP
    const subscription = addSmsListener((event) => {
      const otp = event.message.match(/\b\d{6}\b/)?.[0];
      if (otp) {
        // Option A: Set value in React Hook Form
        setValue('otp', otp, { shouldValidate: true });

        // Option B: Set value using ref directly (Easy & recommended for custom inputs)
        otpInputRef.current?.setValue(otp);
      }
    });

    // 3. Cleanup on unmount
    return () => {
      subscription.remove();
      removeSmsListener();
    };
  }, [setValue]);

  return (
    // Your OTP input UI
    // <OtpInput ref={otpInputRef} ... />
  );
}

API Reference

startSmsUserConsent(senderPhoneNumber?: string): Promise<void>

Starts listening for incoming SMS messages. Optionally filter by sender phone number.

addSmsListener(callback: (event: { message: string }) => void): EventSubscription

Registers a listener for when an SMS is successfully retrieved.

addSmsTimeoutListener(callback: (event: { message: string }) => void): EventSubscription

Registers a listener for timeout or error events.

removeSmsListener(): void

Stops listening for SMS messages. Call this in cleanup.

How it works (Android)

  1. Your app calls startSmsUserConsent().
  2. When an SMS arrives, Google Play Services checks if it contains a one-time code.
  3. If it does, a system-level popup asks: "Allow [App Name] to read the code?".
  4. Once the user taps Allow, the module emits the onSmsReceived event with the full message.

License

MIT