Caution
@shopify/phone
is deprecated.
Shopifolk, see Shopify/quilt-internal for information on the latest packages available for use internally.
Phone number utilities for formatting phone numbers.
yarn add @shopify/phone
import PhoneNumberFormatter from '@shopify/phone';
// Pass a region code to the constructor
const phoneFormatter = new PhoneNumberFormatter('US');
const formatted = phoneFormatter.format(myPhoneNumber);
Formats the given phone number
Update formatter regionCode which will format number based on that (eg: 'CA' | 'JP' etc.)
Returns phone number in E164 format
Returns the non-formatted version without the country code
Indicates if the leading zero of a national number should be retained when dialling internationally
Updates the country code of the formatter based on the phoneNumber passed
Returns the region code from the provided phone number
Returns the country code from the provided phone number