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

simple-country-flags-api-client

v1.0.0

Published

simple-country-flags-api-client is a tiny TypeScript/JavaScript helper that generates type‑safe image URLs for country flags from https://flagsapi.com/ and exposes a curated, strongly‑typed list of supported countries for UI dropdowns and selectors.

Downloads

101

Readme

api-banner-1 npm downloads license NPM Unpacked Size

simple-country-flags-api-client

🇺🇳 simple-country-flags-api-client is a tiny TypeScript/JavaScript helper that generates type‑safe image URLs for country flags from https://flagsapi.com/ and exposes a curated, strongly‑typed list of supported countries for UI dropdowns and selectors.

📦 Installation

npm install --save simple-country-flags-api-client

📚 Features

  1. Type-safe flag URL builder for FlagsAPI
  2. Curated list of all supported country codes and names
  3. Strict typing for flag sizes and styles
  4. Works in both Node.js and client side environments
  5. Zero runtime dependencies, lightweight and fast
  6. Sizes Accepted: 16, 24, 32, 48 and 64. Flag Styles: "flat" or "shiny"

🔤 Example Usage

/* node modules 
import React from "react";
import { getFlagIcon, getSupportedCountries } from "simple-country-flags-api-client";

/* create: a select list of options */
export function CountrySelect() {
  /* get: data */
  const countries = getSupportedCountries();
  /* render - select dropdown */ 
  return (
    <select>
      {countries.map((country) => (
        <option key={country.code} value={country.code}>
          {country.name}
        </option>
      ))}
    </select>
  );
}

/* create a flag-icon component */
export function CountryFlag({ code }: { code: string }) {
  const url = getFlagIcon({ countryCode: code, size: 32, style: "flat" });
  return <img src={url} alt={`${code} flag`} />;
}

📗 Test Coverage

PASS  src/get-supported-countries/test/index.test.ts
  getSupportedCountries
    ✓ returns an array with length greater than zero
    ✓ ensures each item has "name" and "code" string properties
    ✓ ensures each "code" is exactly 2 characters long
    ✓ ensures each code is uppercase
    ✓ ensures there are no duplicate codes

PASS  src/get-flag-icon/test/index.test.ts
  getFlagIcon
    ✓ returns the URL based on the input params
    ✓ returns a URL that contains "https://flagsapi.com" as a substring
    ✓ returns a flat 16px URL in /style/size.png order
    ✓ returns a shiny 64px URL in /style/size.png order
-------------------------|---------|----------|---------|---------|-------------------
File                     | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------------|---------|----------|---------|---------|-------------------
All files                |     100 |      100 |     100 |     100 |                   
 get-flag-icon           |     100 |      100 |     100 |     100 |                   
  index.ts               |     100 |      100 |     100 |     100 |                   
 get-supported-countries |     100 |      100 |     100 |     100 |                   
  index.ts               |     100 |      100 |     100 |     100 |                   
-------------------------|---------|----------|---------|---------|-------------------
Test Suites: 2 passed, 2 total
Tests:       9 passed, 9 total

📘 Contributing

Contributions, suggestions, and improvements are welcome. Feel free to open issues or pull requests.

❤️ Support

Like this project? Support it with a github star, it would mean a lot to me! Cheers and Happy Coding.