Always-fresh, extreme small & easy-to-use international phone masking with Google's libphonenumber data
Quick Start âĒ Packages âĒ Features âĒ Demo âĒ Contributing
Phone formats sync automatically from Google's libphonenumber â no stale data, no manual updates. Just upgrade and you're current with global dialing rules.
13 KB total (4 KB gzipped) with full tree-shaking support. Compare to alternatives:
| Library | Bundle Size (minified) | Gzipped |
|---|---|---|
| @desource/phone-mask | 13 KB | 4 KB |
| react-phone-input-2 | ~80 KB | ~25 KB |
| react-phone-number-input | ~40 KB | ~15 KB |
| intl-tel-input | ~180 KB | ~55 KB |
Ready-made plugins for your stack:
| Package | Version | Description |
|---|---|---|
| @desource/phone-mask | Core library â TypeScript/JS | |
| @desource/phone-mask-react | React component + hook | |
| @desource/phone-mask-vue | Vue 3 component + directive | |
| @desource/phone-mask-nuxt | Nuxt module |
npm install @desource/phone-mask-react
import { PhoneInput } from '@desource/phone-mask-react';
import '@desource/phone-mask-react/assets/lib.css';
function App() {
const [phone, setPhone] = useState('');
return <PhoneInput value={phone} onChange={setPhone} country="US" />;
}
npm install @desource/phone-mask-vue
<script setup>
import { PhoneInput } from '@desource/phone-mask-vue';
import '@desource/phone-mask-vue/assets/lib.css';
const phone = ref('');
</script>
<template>
<PhoneInput v-model="phone" country="US" />
</template>
npm install @desource/phone-mask-nuxt
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@desource/phone-mask-nuxt']
});
<template>
<PhoneInput v-model="phone" country="US" />
</template>
npm install @desource/phone-mask
import { MasksFullMapEn, formatDigitsWithMap } from '@desource/phone-mask';
const mask = MasksFullMapEn.US.mask; // "+1 ###-###-####"
const formatted = formatDigitsWithMap(mask, '2025551234');
// Result: "+1 202-555-1234"
Try the interactive playground with:
We welcome contributions! Please see our Contributing Guide for details.
git clone https://github.com/YOUR_USERNAME/phone-mask.gitpnpm installgit checkout -b feature/my-featuregit commit -m "feat: add awesome feature"git push origin feature/my-feature# Install dependencies
pnpm install
# Build all packages
pnpm build
# Start demo dev server
pnpm dev:demo
# Generate fresh data from Google's library
pnpm gen
Developed and maintained by DeSource Labs.
Created by Stefan Popov
MIT ÂĐ 2026 DeSource Labs