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-sms-consent-api

v1.0.1

Published

A lightweight React Native module for Android's SMS User Consent API. Easily retrieve verification codes from SMS without full SMS permissions.

Readme

📲 react-native-sms-consent-api

A secure and lightweight React Native module for reading one-time passwords (OTP) using Android's SMS User Consent APIwithout SMS permission.

Perfect for apps needing secure OTP verification (e.g., login, signup, password reset).

SMS Consent Demo


✨ Features

  • ✅ No RECEIVE_SMS permission needed
  • ⚡ Automatically handles SMS consent dialog
  • 📤 Emits success/error events
  • 🎣 Hook-based API (useSmsConsent) or manual listener
  • 💬 TypeScript definitions included
  • ⚙️ Works with Android 5.0+ (API 21+)

📦 Installation

npm install @react-native-community/sms-user-consent
# or
yarn add @react-native-community/sms-user-consent

🛠️ Android Setup

1. Autolinking

No manual linking required if using React Native 0.60+.

2. Permissions

📱 Android Permissions Setup

To use the SMS User Consent API, your app must declare the following permissions in AndroidManifest.xml:

🔧 Required Permissions

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_SMS" />

🔧 Usage

✅ 1. Using useSmsConsent Hook

import React from 'react';
import { Text, View } from 'react-native';
import { useSmsConsent } from '@react-native-community/sms-user-consent';

export default function OTPComponent() {
  const otp = useSmsConsent(); // autoStart defaults to true

  return (
    <View>
      <Text>OTP: {otp}</Text>
    </View>
  );
}

🕹️ 2. Manual Start/Stop with autoStart = false

import React, { useEffect, useState } from 'react';
import {
  startSmsConsentWatcher,
  stopSmsConsentWatcher,
  SmsConsentEmitter,
  Events,
  useSmsConsent,
} from '@react-native-community/sms-user-consent';

export default function ManualOtpComponent() {
  const otp = useSmsConsent(false); // ❌ Don't auto-start
  const [code, setCode] = useState<string | null>(null);

  useEffect(() => {
    const received = SmsConsentEmitter.addListener(
      Events.SMS_CONSENT_RECEIVED,
      (event) => {
        console.log('✅ Message received', event.message);
        setCode(event.message);
        stopSmsConsentWatcher();
        received.remove();
      }
    );

    startSmsConsentWatcher();

    return () => {
      stopSmsConsentWatcher();
      received.remove();
    };
  }, []);

  return <Text>OTP Received: {code}</Text>;
}

📘 API Reference

useSmsConsent(autoStart?: boolean): string | null

  • Returns: the retrieved message or OTP
  • autoStart: set to false if you want to trigger startSmsConsentWatcher() manually.

🚀 Event Emitter Constants

Events.SMS_CONSENT_RECEIVED // When message is successfully retrieved
Events.SMS_CONSENT_ERROR    // When an error occurs (e.g., USER_CANCELED)

✅ Supported Platforms

| Platform | Supported | |----------|-----------| | Android | ✅ Yes (API 21+) | | iOS | ❌ No support (Android only) |


🤝 Contributing

Pull requests, bug reports, and feature suggestions welcome! Open an issue


📄 References


🧑‍💻 Author

Made with ❤️ by Antos Maman


📄 License

MIT License