Gathering detailed insights and metrics for use-country-info
Gathering detailed insights and metrics for use-country-info
A custom React Hook designed to retrieve basic country information.
npm install use-country-info
Typescript
Module System
Min. Node Version
Node Version
NPM Version
78.7
Supply Chain
99.5
Quality
84.7
Maintenance
100
Vulnerability
100
License
TypeScript (99.73%)
JavaScript (0.27%)
Total Downloads
2,793
Last Day
2
Last Week
61
Last Month
83
Last Year
1,393
92 Commits
1 Watching
3 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
1.0.27
Package Id
use-country-info@1.0.27
Unpacked Size
1.46 MB
Size
172.52 kB
File Count
6
NPM Version
9.7.2
Node Version
18.16.1
Publised On
17 Dec 2024
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
1,425%
61
Compared to previous week
Last month
-3.5%
83
Compared to previous month
Last year
-0.5%
1,393
Compared to previous year
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.
1npm install use-country-info
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:
1import React from 'react'; 2import { useCountryInfo } from 'use-country-info'; 3 4function PageExample() { 5 const { 6 allCountryInfo, 7 ddiInfo, 8 countryflags 9 } = useCountryInfo(); 10 11 // Render the country data or use it as needed 12 return ( 13 <div> 14 {allCountryInfo.map((item): any => ( 15 <p key={item.name?.common}>{item.capital}</p> 16 ))} 17 </div> 18 ); 19} 20 21export default PageExample;
1{ 2 "name": { 3 "common": "Jordan", 4 "official": "Hashemite Kingdom of Jordan", 5 "nativeName": { 6 "ara": { 7 "official": "المملكة الأردنية الهاشمية", 8 "common": "الأردن" 9 } 10 } 11 }, 12 "tld": [ 13 ".jo", 14 "الاردن." 15 ], 16 "cca2": "JO", 17 "ccn3": "400", 18 "cca3": "JOR", 19 "cioc": "JOR", 20 "independent": true, 21 "status": "officially-assigned", 22 "unMember": true, 23 "currencies": { 24 "JOD": { 25 "name": "Jordanian dinar", 26 "symbol": "د.ا" 27 } 28 }, 29 "countryCallingCode": { 30 "root": "+9", 31 "suffixes": [ 32 "62" 33 ] 34 }, 35 "capital": [ 36 "Amman" 37 ], 38 "altSpellings": [ 39 "JO", 40 "Hashemite Kingdom of Jordan", 41 "al-Mamlakah al-Urdunīyah al-Hāshimīyah" 42 ], 43 "region": "Asia", 44 "subregion": "Western Asia", 45 "languages": { 46 "ara": "Arabic" 47 }, 48 "latlng": [ 49 31, 50 36 51 ], 52 "landlocked": false, 53 "borders": [ 54 "IRQ", 55 "ISR", 56 "PSE", 57 "SAU", 58 "SYR" 59 ], 60 "area": 89342, 61 "demonyms": { 62 "eng": { 63 "f": "Jordanian", 64 "m": "Jordanian" 65 }, 66 "fra": { 67 "f": "Jordanienne", 68 "m": "Jordanien" 69 } 70 }, 71 "flag": "🇯🇴", 72 "maps": { 73 "googleMaps": "https://goo.gl/maps/ko1dzSDKg8Gsi9A98", 74 "openStreetMaps": "https://www.openstreetmap.org/relation/184818" 75 }, 76 "population": 10203140, 77 "gini": { 78 "2010": 33.7 79 }, 80 "fifa": "JOR", 81 "car": { 82 "signs": [ 83 "HKJ" 84 ], 85 "side": "right" 86 }, 87 "timezones": [ 88 "UTC+03:00" 89 ], 90 "continents": [ 91 "Asia" 92 ], 93 "flags": { 94 "png": "https://flagcdn.com/w320/jo.png", 95 "svg": "https://flagcdn.com/jo.svg", 96 "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." 97 }, 98 "coatOfArms": { 99 "png": "https://mainfacts.com/media/images/coats_of_arms/jo.png", 100 "svg": "https://mainfacts.com/media/images/coats_of_arms/jo.svg" 101 }, 102 "startOfWeek": "sunday", 103 "capitalInfo": { 104 "latlng": [ 105 31.95, 106 35.93 107 ] 108 }, 109 "postalCode": { 110 "format": "#####", 111 "regex": "^(\\d{5})$" 112 } 113 },
1 { 2 "countryCallingCode": { 3 "root": "+9", 4 "suffixes": [ 5 "62" 6 ] 7 }, 8 "flag": "🇲🇵", 9 "flags": { 10 "png": "https://flagcdn.com/w320/jo.png", 11 "svg": "https://flagcdn.com/jo.svg", 12 "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." 13 }, 14 }
1 { 2 "name": { 3 "common": "Jordan", 4 "official": "Hashemite Kingdom of Jordan", 5 }, 6 "flag": "🇲🇵", 7 "flags": { 8 "png": "https://flagcdn.com/w320/jo.png", 9 "svg": "https://flagcdn.com/jo.svg", 10 "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." 11 }, 12 }
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.
This project is licensed under the MIT License. See the LICENSE file for more information.
No vulnerabilities found.
No security vulnerabilities found.