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 🙏

© 2024 – Pkg Stats / Ryan Hefner

use-country-info

v1.0.26

Published

use-country-info

Downloads

151

Readme

use-country-info

License

How to works

useCountryInfo is a function that allows you to obtain detailed information about countries in an easy, efficient and synchronous way. From there you can access comprehensive data, such as demographic, geographic and cultural information about any country, directly in your application.

Installation

npm install use-country-info

Usage

Here is a basic example of how to use the useCountryInfo function in a React component, but it can be used in any front end that needs it as it has no codependency:

import React from 'react';
import { useCountryInfo } from 'use-country-info';

function PageExample() {
  const {
    allCountryInfo,
    ddiInfo,
    countryflags
  } = useCountryInfo();

  // Render the country data or use it as needed
  return (
    <div>
      {allCountryInfo.map((item): any => (
        <p key={item.name?.common}>{item.capital}</p>
      ))}
    </div>
  );
}

export default PageExample;

Objects example

{
    "name": {
      "common": "Jordan",
      "official": "Hashemite Kingdom of Jordan",
      "nativeName": {
        "ara": {
          "official": "المملكة الأردنية الهاشمية",
          "common": "الأردن"
        }
      }
    },
    "tld": [
      ".jo",
      "الاردن."
    ],
    "cca2": "JO",
    "ccn3": "400",
    "cca3": "JOR",
    "cioc": "JOR",
    "independent": true,
    "status": "officially-assigned",
    "unMember": true,
    "currencies": {
      "JOD": {
        "name": "Jordanian dinar",
        "symbol": "د.ا"
      }
    },
    "countryCallingCode": {
      "root": "+9",
      "suffixes": [
        "62"
      ]
    },
    "capital": [
      "Amman"
    ],
    "altSpellings": [
      "JO",
      "Hashemite Kingdom of Jordan",
      "al-Mamlakah al-Urdunīyah al-Hāshimīyah"
    ],
    "region": "Asia",
    "subregion": "Western Asia",
    "languages": {
      "ara": "Arabic"
    },
    "latlng": [
      31,
      36
    ],
    "landlocked": false,
    "borders": [
      "IRQ",
      "ISR",
      "PSE",
      "SAU",
      "SYR"
    ],
    "area": 89342,
    "demonyms": {
      "eng": {
        "f": "Jordanian",
        "m": "Jordanian"
      },
      "fra": {
        "f": "Jordanienne",
        "m": "Jordanien"
      }
    },
    "flag": "🇯🇴",
    "maps": {
      "googleMaps": "https://goo.gl/maps/ko1dzSDKg8Gsi9A98",
      "openStreetMaps": "https://www.openstreetmap.org/relation/184818"
    },
    "population": 10203140,
    "gini": {
      "2010": 33.7
    },
    "fifa": "JOR",
    "car": {
      "signs": [
        "HKJ"
      ],
      "side": "right"
    },
    "timezones": [
      "UTC+03:00"
    ],
    "continents": [
      "Asia"
    ],
    "flags": {
      "png": "https://flagcdn.com/w320/jo.png",
      "svg": "https://flagcdn.com/jo.svg",
      "alt": "The flag of Jordan is composed of three equal horizontal bands of black, white and green, with a red isosceles triangle superimposed on the hoist side of the field. This triangle has its base on the hoist end, spans about half the width of the field and bears a small seven-pointed white star at its center."
    },
    "coatOfArms": {
      "png": "https://mainfacts.com/media/images/coats_of_arms/jo.png",
      "svg": "https://mainfacts.com/media/images/coats_of_arms/jo.svg"
    },
    "startOfWeek": "sunday",
    "capitalInfo": {
      "latlng": [
        31.95,
        35.93
      ]
    },
    "postalCode": {
      "format": "#####",
      "regex": "^(\\d{5})$"
    }
  },
  {
    "countryCallingCode": {
      "root": "+9",
      "suffixes": [
        "62"
      ]
    },
    "flag": "🇲🇵",
    "flags": {
      "png": "https://flagcdn.com/w320/jo.png",
      "svg": "https://flagcdn.com/jo.svg",
      "alt": "The flag of Jordan is composed of three equal horizontal bands of black, white and green, with a red isosceles triangle superimposed on the hoist side of the field. This triangle has its base on the hoist end, spans about half the width of the field and bears a small seven-pointed white star at its center."
    },
  }
  {
    "name": {
      "common": "Jordan",
      "official": "Hashemite Kingdom of Jordan",
    },
    "flag": "🇲🇵",
    "flags": {
      "png": "https://flagcdn.com/w320/jo.png",
      "svg": "https://flagcdn.com/jo.svg",
      "alt": "The flag of Jordan is composed of three equal horizontal bands of black, white and green, with a red isosceles triangle superimposed on the hoist side of the field. This triangle has its base on the hoist end, spans about half the width of the field and bears a small seven-pointed white star at its center."
    },
  }

Contribution

This is an open-source project, and we welcome contributions from the community. If you encounter issues, bugs, or have ideas for improvements, feel free to open an issue or submit a pull request in the official repository on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for more information.