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

react-native-country-flag-icons

v1.0.0

Published

Tree-shakeable country flag icons for React Native with SVG support

Downloads

37

Readme

react-native-country-flag-icons

Tree-shakeable country flag icons for React Native with SVG support.

Only bundle the flags you actually use.

Why This Library?

| Feature | react-native-country-flag-icons | react-native-ico-flags | react-native-svg-flagkit | |---------|:------------------------------:|:----------------------:|:------------------------:| | Tree-shaking | ✅ | ❌ | ❌ | | Bundle size (3 flags) | ~3KB | ~358KB | ~64MB | | SVG (scalable) | ✅ | ✅ | ❌ (PNG) | | TypeScript | ✅ | ❌ | ❌ | | Expo compatible | ✅ | ✅ | ❌ | | Dynamic flag component | ✅ | ✅ | ✅ | | ESM + CommonJS | ✅ | ❌ | ❌ |

The Problem

Most React Native flag libraries bundle all flags regardless of how many you use:

Your app uses 5 flags → Downloads 300+ flags → Bundle bloat 📦💥

The Solution

With tree-shaking, your bundle only includes flags you actually import:

Your app uses 5 flags → Bundles only 5 flags → Minimal bundle size ✨

Features

  • Tree-shakeable - Import only what you need, bundle only what you use
  • Lightweight - ~1KB per flag vs 300KB+ for entire flag libraries
  • SVG-based - Crisp flags at any resolution using react-native-svg
  • TypeScript - Full type definitions with CountryCode type and FlagProps
  • 265 flags - All countries with ISO 3166-1 alpha-2 codes + regional flags
  • Expo compatible - Works with Expo (requires expo-dev-client for react-native-svg)
  • Dual package - Supports both ESM and CommonJS

Installation

# npm
npm install react-native-country-flag-icons react-native-svg

# yarn
yarn add react-native-country-flag-icons react-native-svg

React Native CLI

cd ios && pod install

Expo

npx expo install react-native-svg

Note: react-native-svg requires a development build. Run npx expo run:ios or npx expo run:android after installation.

Usage

Named imports (recommended for tree-shaking)

Best for static flags where you know the country codes at build time:

import {US, KR, JP} from 'react-native-country-flag-icons'

function MyComponent() {
  return (
    <>
      <US width={32} />
      <KR width={32} />
      <JP width={32} />
    </>
  )
}

Dynamic Flag component

For dynamic country codes (e.g., from API), use the Flag component:

import {Flag} from 'react-native-country-flag-icons'

function CountryItem({countryCode}: {countryCode: string}) {
  return <Flag code={countryCode} width={32} />
}

Note: The dynamic Flag component imports all flags internally, so tree-shaking won't apply. Use named imports when possible for optimal bundle size.

Custom dimensions

import {US} from 'react-native-country-flag-icons'

// Width only (height auto-calculated with 3:2 aspect ratio)
<US width={48} />

// Both width and height
<US width={48} height={32} />

With styles

import {US} from 'react-native-country-flag-icons'

<US
  width={32}
  style={{borderRadius: 4, overflow: 'hidden'}}
/>

Props

Named Flag Components (US, KR, JP, ...)

| Prop | Type | Default | Description | |------|------|---------|-------------| | width | number | 32 | Width in pixels | | height | number | width / 1.5 | Height (auto-calculated if not provided) | | style | ViewStyle | - | Style for the SVG container | | ...props | SvgProps | - | All other props passed to SVG |

Dynamic Flag Component

| Prop | Type | Default | Description | |------|------|---------|-------------| | code | CountryCode | required | ISO 3166-1 alpha-2 country code | | width | number | 32 | Width in pixels | | height | number | width / 1.5 | Height (auto-calculated if not provided) | | style | ViewStyle | - | Style for the SVG container |

Available Flags

All 265 flags use ISO 3166-1 alpha-2 country codes:

import {
  US,  // United States
  KR,  // South Korea
  JP,  // Japan
  CN,  // China
  GB,  // United Kingdom
  FR,  // France
  DE,  // Germany
  // ... and 258 more
} from 'react-native-country-flag-icons'

Regional flags

import {
  GB_ENG,  // England
  GB_SCT,  // Scotland
  GB_WLS,  // Wales
  GB_NIR,  // Northern Ireland
  ES_CT,   // Catalonia
} from 'react-native-country-flag-icons'

TypeScript

Full TypeScript support with exported types:

import {
  US,
  Flag,
  FlagProps,
  CountryCode,
  countryCodes
} from 'react-native-country-flag-icons'

// FlagProps type for custom wrappers
const MyFlag: React.FC<FlagProps> = (props) => <US {...props} />

// CountryCode type for type-safe country codes
const code: CountryCode = 'US'

// countryCodes array for validation or iteration
if (countryCodes.includes(userInput as CountryCode)) {
  // valid country code
}

Bundle Size Comparison

| Scenario | This Library | react-native-ico-flags | react-native-svg-flagkit | |----------|-------------:|----------------------:|-------------------------:| | 1 flag | ~1KB | ~358KB | ~64MB | | 5 flags | ~5KB | ~358KB | ~64MB | | 10 flags | ~10KB | ~358KB | ~64MB | | All flags | ~300KB | ~358KB | ~64MB |

Credits

License

MIT