Registry / messaging / phoneformat-react-native

phoneformat-react-native

JSON →
library1.0.3jsnpmunverified

A JavaScript phone number formatting library targeting React Native, based on an outdated (2015) snapshot of Google's libphonenumber. Version 1.0.3 is the only published version, with no updates since. The README notes it is not frequently synced with the latest libphonenumber, meaning validation and formatting may be stale. Offers APIs for E164, international, local formatting, validation, and country lookup. Compared to actively maintained alternatives like libphonenumber-js or react-native-phone-number-input, this package is effectively frozen and should be avoided for new projects.

npm install phoneformat-react-native
INSTALL
IMPORT
SIG · PHONEFORMAT-REACT-
P
phoneformat-react-native
messagingjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

phoneFormat
import phoneFormat from 'phoneformat-react-native';
const { phoneFormat } = require('phoneformat-react-native');
The package exports a default object. Using named import will result in undefined.
isValidNumber
import phoneFormat from 'phoneformat-react-native'; phoneFormat.isValidNumber('...', 'US');
import { isValidNumber } from 'phoneformat-react-native';
isValidNumber is a method on the default export, not a named export.
formatE164
import phoneFormat from 'phoneformat-react-native'; phoneFormat.formatE164('US', '...');
import { formatE164 } from 'phoneformat-react-native';
formatE164 is a method on the default export, not a named export.
formatLocal
import phoneFormat from 'phoneformat-react-native'; phoneFormat.formatLocal('US', '...');
Uses default export, then calls formatLocal with country code and number.

Shows how to import the default export and use the main formatting and validation functions with a US phone number.

import phoneFormat from 'phoneformat-react-native'; const number = '+14155552671'; const country = phoneFormat.countryForE164Number(number); // 'US' const e164 = phoneFormat.formatE164('US', number); // '+14155552671' const local = phoneFormat.formatLocal('US', number); // '(415) 555-2671' const mobile = phoneFormat.formatNumberForMobileDialing('US', number); // '+14155552671' const isValid = phoneFormat.isValidNumber(number, 'US'); // true|false const example = phoneFormat.exampleMobileNumber('US'); // a US mobile example number console.log({ country, e164, local, mobile, isValid, example });
Debug
Known issues
deprecatedlibphonenumber data is from 2015; phone number validation and formatting may be incorrect for many countries.
fix
Use an actively maintained library like libphonenumber-js or react-native-phone-number-input.
affects: >=1.0.0
gotchaThe package requires React Native runtime; it will not work in plain Node.js or browser environments without a bundler.
fix
Ensure you are using this package only within a React Native project.
affects: >=1.0.0
gotchaDefault export is the only export; destructuring individual functions will result in undefined.
fix
Import as default: import phoneFormat from 'phoneformat-react-native';
affects: >=1.0.0
deprecatedNo updates since 2018; package is unmaintained and may have known security issues.
fix
Switch to a maintained alternative.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: undefined is not an object (evaluating 'phoneFormat.isValidNumber')
Using named import: import { isValidNumber } from 'phoneformat-react-native'; returns undefined.
fix
Use default import: import phoneFormat from 'phoneformat-react-native'; then call phoneFormat.isValidNumber(...).
Cannot find module 'phoneformat-react-native'
Package not installed in node_modules or React Native packager not started.
fix
Run 'npm install phoneformat-react-native' and ensure React Native metro bundler is running.
Invalid phone number for country code 'XX'
Outdated libphonenumber data; country codes or numbering plans have changed since 2015.
fix
Update the underlying library or switch to a current solution.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
19 hits · last 30 days
node
16
OpenAI (training)
1
Resources
phoneformat-react-native — npm install phoneformat-react-native · libregistry