Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide
DocumentationUtilsuseTelephoneCountryCodes

useTelephoneCountryCodes

A hook to provide a list of telephone country codes as an array of strings.

Import

import { useTelephoneCountryCodes } from '@krakentech/utils';

Usage

Return all country codes

const { telephoneCountryCodes } = useTelephoneCountryCodes();

Include

Return only France and Spain country codes

const { telephoneCountryCodes } = useTelephoneCountryCodes({ include: ['FRA', 'ESP'], });

Exclude

Returns all country codes except France

const { telephoneCountryCodes } = useTelephoneCountryCodes({ exclude: ['FRA'], });

Args

NameDescriptionTypeDefaultRequired
includeThe country codes to include in the returned datasetstring[] (string to be ISOAlpha3 value)false
excludeThe country codes to exclude from the returned datasetstring[] (string to be ISOAlpha3 value)false

Returns

NameTypeDescriptionExample
telephoneCountryCodesstring[]An array of country codes alongside the country name: eg['+33 France', '+34 Spain', ...]

Notes

  • The dataset that powers this hook has been sourced from this link  🔗
  • The dataset has been adjusted slightly to suit our needs
Last updated on