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-phone-number-input-pro

v1.0.2

Published

A highly customizable React component for international phone number input with built-in country detection, strict validation, and zero runtime dependencies.

Readme

react-phone-number-input-pro

A zero-dependency React component for international phone number input with country selection, auto-formatting, and validation for 240+ countries.

npm version bundle size license TypeScript

Features

  • 🌍 240+ countries — complete dataset with dial codes and crisp SVG flags (via FlagCDN)
  • 🔍 Searchable dropdown — filter by country name, code, or dial code
  • Per-country validation — custom regex + length rules for every country
  • 🎭 Auto-format — masks number as you type (e.g. 98765 43210)
  • 📋 Paste detection — paste +919876543210 and it auto-selects country
  • 🌎 Auto-detect country — reads browser locale on mount
  • 🎨 CSS variables theming — full customization, dark mode included
  • 🔌 Headless hookusePhoneInput() for custom UI
  • 📦 Zero dependencies — only peer deps: react >=17
  • 💪 TypeScript — 100% typed, types shipped with package

Installation

npm install react-phone-number-input-pro

Quick Start

import { PhoneInput } from 'react-phone-number-input-pro';
import 'react-phone-number-input-pro/styles';

function MyForm() {
  return (
    <PhoneInput
      defaultCountry="auto"
      onChange={(value, meta) => {
        console.log(value);        // "+919876543210"
        console.log(meta.isValid); // true
        console.log(meta.country); // "IN"
      }}
    />
  );
}

Props

| Prop | Type | Default | Description | |---|---|---|---| | value | string | — | Controlled value (full international number) | | onChange | (value, meta) => void | — | Called on every change | | defaultCountry | string | "auto" | ISO code or "auto" to detect from browser | | placeholder | string | "Phone number" | Input placeholder | | disabled | boolean | false | Disables the component | | error | boolean | false | Forces error state (red border) | | className | string | — | Extra class on wrapper | | style | CSSProperties | — | Extra inline styles | | name | string | — | Input name attribute | | id | string | — | Input id attribute | | required | boolean | — | Input required attribute | | onBlur | () => void | — | Focus out callback | | onFocus | () => void | — | Focus in callback |

onChange meta object

interface PhoneChangeMeta {
  country: string;        // "IN"
  dialCode: string;       // "+91"
  nationalNumber: string; // "98765 43210" (formatted)
  rawNumber: string;      // "9876543210"  (digits only)
  isValid: boolean;       // true
}

Headless Hook

Build your own UI while using all the logic:

import { usePhoneInput } from 'react-phone-number-input-pro';

function CustomPhoneInput() {
  const {
    country,
    setCountry,
    nationalNumber,
    setNationalNumber,
    formatted,
    fullNumber,
    isValid,
    error,
    reset,
  } = usePhoneInput({ defaultCountry: 'auto' });

  return (
    <div>
      <span>{country.dialCode}</span>
      <input
        value={formatted}
        onChange={(e) => setNationalNumber(e.target.value)}
      />
      {error && <p>{error}</p>}
    </div>
  );
}

Theming with CSS Variables

.my-phone-input {
  --rpi-border-radius:     12px;
  --rpi-border-color:      #8b5cf6;
  --rpi-border-color-focus:#7c3aed;
  --rpi-border-color-valid: #10b981;
  --rpi-border-color-error: #f43f5e;
  --rpi-font-size:         1rem;
  --rpi-height:            52px;
  --rpi-trigger-width:     110px;
}
<PhoneInput className="my-phone-input" defaultCountry="auto" />

Available CSS Variables

| Variable | Default | Description | |---|---|---| | --rpi-font-size | 0.9375rem | Text size | | --rpi-height | 46px | Input height | | --rpi-border-color | #d1d5db | Border color | | --rpi-border-color-focus | #6366f1 | Focus border | | --rpi-border-color-valid | #22c55e | Valid border | | --rpi-border-color-error | #ef4444 | Error border | | --rpi-border-radius | 10px | Corner radius | | --rpi-bg | #ffffff | Background | | --rpi-trigger-width | 96px | Country selector width | | --rpi-dropdown-width | 300px | Dropdown panel width | | --rpi-dropdown-max-height | 300px | Dropdown scroll height |


Using Utilities Directly

import { validatePhone, countries, getCountryByCode } from 'react-phone-number-input-pro';

// Validate a number
const { isValid, error } = validatePhone('9876543210', 'IN');

// Look up a country
const india = getCountryByCode('IN');
// { name: "India", code: "IN", dialCode: "+91" }

// Access the full list
console.log(countries.length); // 240

Browser Support

All modern browsers. Flags are served dynamically via high-quality CDNs, guaranteeing perfect rendering on Windows, Mac, iOS, and Android (bypassing Windows' lack of native flag emoji support). Works flawlessly in React 17, 18, and 19.


License

MIT © saafir-bhimani