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

lite-phone-input

v0.5.0

Published

Lightweight phone input with formatting, validation, and emoji flags — ~13KB gzipped

Readme

lite-phone-input

npm version bundle size license

Lightweight phone input with format-as-you-type, validation, and emoji flags. ~13KB gzipped total — zero runtime dependencies.

Why lite-phone-input?

| | lite-phone-input | intl-tel-input | |---|---|---| | JS bundle | ~13KB (includes formatting + validation) | ~15KB + ~260KB utils | | Flag assets | Emoji (0KB) | Webp sprites (30–66KB) | | Dependencies | 0 | Flag sprites + optional utils | | Formatting | Built-in | Requires utils bundle | | Validation | Built-in | Requires utils bundle |

Features

  • ~13KB gzipped (JS + country data) — includes formatting AND validation
  • Emoji flags computed from ISO code at runtime (zero image cost)
  • Format-as-you-type with per-country masks (~240 countries)
  • Per-country length validation with rich error data
  • TypeScript-first with full type definitions
  • Framework adapters — Vanilla JS, React, Preact
  • Accessible — WCAG 2.1 AA, ARIA combobox pattern, keyboard navigation
  • SSR-safe — no browser API calls at module level

Installation

npm install lite-phone-input

Quick Start

Vanilla JS

import { PhoneInput } from 'lite-phone-input/vanilla';
import 'lite-phone-input/styles';

const phone = PhoneInput.mount(document.getElementById('phone'), {
  defaultCountry: 'US',
  separateDialCode: true,
  onChange(e164, country, validation) {
    console.log(e164);           // '+12025551234'
    console.log(country.code);   // 'US'
    console.log(validation.valid); // true
  },
});

React

import { useRef } from 'react';
import { PhoneInput } from 'lite-phone-input/react';
import 'lite-phone-input/styles';

function MyForm() {
  const phoneRef = useRef(null);

  return (
    <PhoneInput
      ref={phoneRef}
      defaultCountry="US"
      separateDialCode
      initialValue="+12025551234"
      onChange={(e164) => console.log(e164)}
      name="phone"
      aria-label="Phone number"
    />
  );
}

Preact

import { PhoneInput } from 'lite-phone-input/preact';
import 'lite-phone-input/styles';

Same API as React. Uses preact/hooks directly — no preact/compat required.

CDN / Script Tag

<link rel="stylesheet" href="https://unpkg.com/lite-phone-input/dist/styles.css">
<script src="https://unpkg.com/lite-phone-input/dist/vanilla/index.global.js"></script>
<script>
  const phone = LitePhoneInput.PhoneInput.mount(document.getElementById('phone'), {
    defaultCountry: 'US',
  });
</script>

Geo IP Lookup

Auto-detect the user's country at mount time using any geo-IP service. The lookup runs once, and the result is ignored if the user has already interacted with the widget.

const phone = PhoneInput.mount(document.getElementById('phone'), {
  defaultCountry: 'US',
  geoIpLookup: (callback) => {
    // Cloudflare (free, no API key)
    fetch('/cdn-cgi/trace')
      .then(res => res.text())
      .then(text => {
        const match = text.match(/loc=(\w+)/);
        callback(match ? match[1] : null);
      })
      .catch(() => callback(null));
  },
});
// Alternative: ipapi.co
geoIpLookup: (callback) => {
  fetch('https://ipapi.co/json/')
    .then(res => res.json())
    .then(data => callback(data.country_code))
    .catch(() => callback(null));
}

Documentation

| Guide | Description | |---|---| | Getting Started | Installation and first render | | Vanilla JS Guide | Mounting, methods, callbacks | | React Guide | Usage, ref methods, form libraries | | Preact Guide | Preact-specific setup | | API Reference | All options, methods, and types | | Styling & Theming | CSS variables, BEM classes, dark mode | | Validation | Validation model and error messages | | Form Integration | Hidden inputs, RHF, Formik | | Core Utilities | Headless/server-side functions | | Accessibility | ARIA patterns, keyboard navigation | | Advanced Topics | SSR, RTL, i18n, portals | | Migration from intl-tel-input | Comparison and migration guide |

Browser Support

Chrome 80+, Firefox 80+, Safari 14+, Edge 80+. No IE support, no polyfills needed.

Contributing

See CONTRIBUTING.md for development setup and guidelines.

Changelog

See CHANGELOG.md for release history.

License

MIT