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

country-info-flags

v1.3.16

Published

A lightweight library for country flags, phone codes, and currency information for React and React Native

Readme

country-info-flags

A lightweight, versatile library for displaying country flags and accessing country information in React and React Native applications.

npm version license

Features

  • 🚩 SVG country flags for all countries
  • 📱 Compatible with both React and React Native
  • 📞 Country phone codes
  • 💰 Currency information
  • 🔄 TypeScript support
  • 🔍 Country code lookup

Installation

# npm
npm install country-info-flags

# yarn
yarn add country-info-flags

# pnpm
pnpm add country-info-flags

For React Native, you'll need additional dependencies:

npm install react-native-svg

Usage

Country Flags Component Basic usage - default size is 300x300

import { CountryFlag } from 'country-info-flags';

// Basic usage - default size is 300x300
<CountryFlag countryCode="US" />

Custom size

<CountryFlag countryCode="FR" width={40} height={30} />

Responsive design

<CountryFlag countryCode="JP" width="100%" height={50} />

Country Information Functions

Get Phone Number Code

import { getPhoneNumberCode } from 'country-info-flags';

// Get phone code for a country
const usInfo = getPhoneNumberCode('US');
console.log(usInfo);
// Output: { code: 'US', name: 'United States of America', phoneCode: '+1' }

// With error handling
const unknownCountry = getPhoneNumberCode('ZZZ');
if (unknownCountry.notFound) {
  console.log(unknownCountry.message); // Country with code 'ZZZ' not found
}

// Custom error message
const custom = getPhoneNumberCode('ZZZ', 'Invalid country code provided');
if (custom.notFound) {
  console.log(custom.message); // Invalid country code provided
}

Get Country Currency Code

import { getCountryCurrencyCode } from 'country-info-flags';

// Get currency for a country
const euroCurrency = getCountryCurrencyCode('DE');
console.log(euroCurrency);
// Output: { code: 'DE', name: 'Germany', currency: 'EUR' }

Get All Country Currencies

import { getAllCountryCurrencies } from 'country-info-flags';

// Get all countries with their currencies
const allCurrencies = getAllCountryCurrencies();
console.log(allCurrencies[0]);
// Output: { code: 'AF', name: 'Afghanistan', currency: 'AFN' }

Get All Phone Codes

import { getAllPhoneCurrencies } from 'country-info-flags';

// Get all countries with their phone codes
const allPhoneCodes = getAllPhoneCurrencies();
console.log(allPhoneCodes[0]);
// Output: { code: 'AF', name: 'Afghanistan', phoneCode: '+93' }

Country Flag Example Here's what the flag components look like:

<div style={{ display: 'flex', gap: 10 }}>
  <CountryFlag countryCode="US" height={30} />
  <CountryFlag countryCode="CA" height={30} />
  <CountryFlag countryCode="GB" height={30} />
  <CountryFlag countryCode="JP" height={30} />
  <CountryFlag countryCode="IN" height={30} />
</div>

API Reference

UI Components _CountryFlag _

| Prop | Type | Default | Description | |-------------|--------|---------|---------------------------------------| | countryCode | string | | ISO 3166-1 alpha-2 country code | | height | number | 20 | Height of the flag (pixels) | | width | number | 20 | Width of the flag (pixels) |

Data Functions

getPhoneNumberCode(countryCode, errorMessage?) Returns phone code information for a country.

getCountryCurrencyCode(countryCode, errorMessage?) Returns currency information for a country.

getAllCountryCurrencies() Returns a list of all countries with their currencies.

Country Flag Example Returns a list of all countries with their phone codes.

License

MIT