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

rn-phonenumber-detector

v1.0.9

Published

Auto-detect and fetch phone number on Android via Google Identity API.

Downloads

782

Readme

rn-phonenumber-detector


Installation

yarn add rn-phonenumber-detector
# or
npm install rn-phonenumber-detector

Android Setup

Add to android/app/build.gradle:

dependencies {
    implementation 'com.google.android.gms:play-services-auth:21.0.0'
}

Then rebuild:

cd android && ./gradlew clean
cd ..
npx react-native run-android

That's it! Auto-linking handles the rest. ✅


Usage

Option 1 — Direct call (recommended)

Best when you already have your own hook or state management:

import { requestPhoneHint } from 'rn-phonenumber-detector';
import { Platform } from 'react-native';

const triggerPhoneHint = () => {
  if (Platform.OS !== 'android') return;

  requestPhoneHint()
    .then((number) => {
      // number comes as +91XXXXXXXXXX
      const stripped = number.replace(/^\+91/, '').trim();
      setInputValue(stripped); // wire to your input state
    })
    .catch(() => {
      // silent fail — user dismissed or no number found
    });
};

// call it when screen is focused
useEffect(() => {
  triggerPhoneHint();
}, []);

Option 2 — Hook

Best for simple use cases where you manage phone input directly:

import { usePhoneHint } from 'rn-phonenumber-detector';

const MyScreen = () => {
  const [inputValue, setInputValue] = useState('');

  const { triggerHint, loading } = usePhoneHint({
    countryCallingCode: '91',
    onSuccess: (number) => setInputValue(number),
    onError: () => {},
  });

  useEffect(() => {
    triggerHint();
  }, []);

  return (
    <TextInput
      value={inputValue}
      onChangeText={setInputValue}
      keyboardType="number-pad"
      textContentType="telephoneNumber"
      placeholder="Enter phone number"
    />
  );
};

iOS

No extra code needed. Just add these props to your TextInput:

<TextInput
  keyboardType="number-pad"
  textContentType="telephoneNumber"
/>

API

requestPhoneHint()

requestPhoneHint(): Promise<string>

| | | |---|---| | Returns | Promise<string> — full number e.g. +919876543210 | | Platform | Android only | | Fails | If user dismisses or no number found |


usePhoneHint(options)

Options:

| Option | Type | Default | Description | |---|---|---|---| | countryCallingCode | string | '91' | Strips country code prefix from result | | onSuccess | (number: string) => void | — | Called with stripped local number | | onError | (error: Error) => void | — | Called on failure or dismiss |

Returns:

| Value | Type | Description | |---|---|---| | phoneNumber | string | Auto-fetched local number | | loading | boolean | true while hint is being fetched | | error | string \| null | Error message if failed | | triggerHint | () => void | Call this to show the Google picker |


Platform Support

| Platform | Support | Method | |---|---|---| | Android | ✅ | Google Identity Hint API | | iOS | ✅ | textContentType='telephoneNumber' |


Notes

  • Works only on real devices — not emulators
  • Requires Google Play Services on Android
  • Fails silently if no number found — user types manually
  • Number format from requestPhoneHint: +91XXXXXXXXXX
  • Number format from usePhoneHint onSuccess: XXXXXXXXXX (country code stripped)

Changelog

v1.0.7

  • Added auto-linking support
  • Improved README with complete usage docs
  • Added more keywords for discoverability

v1.0.1

  • Initial release
  • Android Google Identity API support
  • requestPhoneHint direct call
  • usePhoneHint hook

Contributing

Contributions are welcome! Here's how:

  1. Fork the repo
  2. Create your branch:
git checkout -b feature/my-feature
  1. Commit your changes:
git commit -m "add my feature"
  1. Push to your branch:
git push origin feature/my-feature
  1. Open a Pull Request on GitHub

Please make sure your code:

  • Has no TypeScript errors (npm run build)
  • Is tested on a real Android device
  • Updates the README if needed

License

MIT © Madhurmeet Jadhav