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

react-native-auto-otp-listener

v0.1.7

Published

With the react-native-auto-otp-listener, you can perform SMS-based user verification in your Android app automatically, without requiring the user to manually type verification codes, and without requiring any extra app permissions.

Downloads

4

Readme

react-native-auto-otp-listener

With react-native-auto-otp-listener, you can perform SMS-based user verification in your Android app automatically —
without requiring the user to manually type verification codes and without needing any extra app permissions.


Demo

https://github.com/user-attachments/assets/5e36cded-c5c6-4d83-9b97-01d472d3d513

Installation

npm install react-native-auto-otp-listener
yarn add react-native-auto-otp-listener

import { useEffect, useState } from 'react';
import { Text, View, StyleSheet, Button, Alert } from 'react-native';
import {
  startListeningForOTP,
  stopListeningForOTP,
  addOTPListener,
  addOTPErrorListener,
  getAppHash,
} from 'react-native-auto-otp-listener';

export default function App() {
  const [otp, setOtp] = useState<string | null>(null);
  const [error, setError] = useState<string | null>(null);
  const [appHash, setAppHash] = useState<string | null>(null); // Store the app hash here

  useEffect(() => {
    const fetchAppHash = async () => {
      try {
        const hash = await getAppHash();
        console.log('✅ App hash for SMS:', hash);
        setAppHash(hash); // Set app hash in state
      } catch (err) {
        console.error('❌ Error getting app hash:', err);
      }
    };

    fetchAppHash(); // Call the async function

    startListeningForOTP();

    const otpSub = addOTPListener((receivedOtp) => {
      console.log('Received OTP:', receivedOtp);

      // Extract the 6-digit OTP from the SMS
      const otpMatch = receivedOtp.match(/\d{6}/); // Regex to find 6 digits
      if (otpMatch) {
        setOtp(otpMatch[0]);
        Alert.alert('OTP Received', otpMatch[0]);
      } else {
        setError('No 6-digit OTP found');
      }
    });

    const errorSub = addOTPErrorListener((err) => {
      console.warn('OTP error:', err);
      setError(err);
    });

    return () => {
      stopListeningForOTP();
      otpSub.remove();
      errorSub.remove();
    };
  }, []);

  return (
    <View style={styles.container}>
      <Text style={styles.title}>React Native Auto OTP Listener Demo</Text>
      {appHash && <Text style={styles.text}>App Hash: {appHash}</Text>}{' '}
      {/* Display App Hash */}
      <Text style={styles.text}>
        Received OTP: {otp ?? 'Waiting for OTP...'}
      </Text>
      {error && <Text style={styles.error}>Error: {error}</Text>}
      <Button title="Clear OTP" onPress={() => setOtp(null)} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#f9f9f9',
    alignItems: 'center',
    justifyContent: 'center',
    padding: 10,
  },
  title: {
    fontSize: 22,
    fontWeight: 'bold',
    marginBottom: 20,
  },
  text: {
    fontSize: 16,
    marginVertical: 40,
    fontWeight: '500',
    color: 'red',
  },
  error: {
    fontSize: 14,
    color: 'red',
    marginVertical: 20,
  },
});