https://github.com/razumolla/country-info-finder
This is the NPM Package for fetch all country details information.
https://github.com/razumolla/country-info-finder
country-information hooks npm package
Last synced: 3 months ago
JSON representation
This is the NPM Package for fetch all country details information.
- Host: GitHub
- URL: https://github.com/razumolla/country-info-finder
- Owner: razumolla
- Created: 2024-07-10T08:38:22.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-11T09:51:14.000Z (11 months ago)
- Last Synced: 2025-02-15T06:49:10.966Z (4 months ago)
- Topics: country-information, hooks, npm, package
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/country-info-finder
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# country-info-finder
A ReactJS hook to get the country information.
## ⭐ Support
Liked it? Show your support with a STAR (⭐).
### Many Thanks to all the `Stargazers` who have supported this project with stars (⭐)
[](https://github.com/razumolla/country-info-finder/stargazers)
## 📦 Installation
You can install the package using npm or yarn:
```bash
# npm
npm install country-info-finder# yarn
yarn add country-info-finder
```### 🚀 Usage
1. `useCountry` Hook
**Import the package in your app -**
```js
import { useCountry } from "country-info-finder";
```**Get country information using the hook -**
```js
const { loading, error, country } = useCountry("Bangladesh");
```**Example Component :** Here is an example of how you can use the `useCountry` hook in a React component:
```js
import { useCountry } from "country-info-finder";function App() {
const { loading, error, country } = useCountry("Bangladesh");if (loading) return
Loading...
;
if (error) returnError: {error.message}
;const data = country[0];
return (
Country Information
Official Name: {data?.name.official}
Common Name: {data?.name.common}
Flag: {data?.flag}
);
}export default App;
```2. `useAllCountries` Hook
**Import the package in your app -**
```js
import { useAllCountries } from "country-info-finder";
```**Get all countries' information from the hook: -**
```js
const { loading, error, countries } = useAllCountries();
```**Example Component :** Here is an example of how you can use the `useAllCountries` hook in a React component:
```js
import { useAllCountries } from "country-info-finder";function App() {
const { loading, error, countries } = useAllCountries();if (loading) return
Loading...
;
if (error) return{error}
;return (
-
{country.name.common} - {country.flag}
{countries.map((country) => (
))}
);
}
export default App;
```
### 🌐 Example Country Data
```josn
[
{
"name": {
"common": "Bangladesh",
"official": "People's Republic of Bangladesh",
"nativeName": {
"ben": {
"official": "বাংলাদেশ গণপ্রজাতন্ত্রী",
"common": "বাংলাদেশ"
}
}
},
"tld": [".bd"],
"cca2": "BD",
"ccn3": "050",
"cca3": "BGD",
"cioc": "BAN",
"independent": true,
"status": "officially-assigned",
"unMember": true,
"currencies": {
"BDT": {
"name": "Bangladeshi taka",
"symbol": "৳"
}
},
"idd": {
"root": "+8",
"suffixes": ["80"]
},
"capital": ["Dhaka"],
"altSpellings": [
"BD",
"People's Republic of Bangladesh",
"Gônôprôjatôntri Bangladesh"
],
"region": "Asia",
"subregion": "Southern Asia",
"languages": {
"ben": "Bengali"
},
"translations": {
"ara": {
"official": "جمهورية بنغلاديش الشعبية",
"common": "بنغلاديش"
},
"deu": {
"official": "Volksrepublik Bangladesch",
"common": "Bangladesch"
},
// Additional translations omitted for brevity
},
"latlng": [24, 90],
"landlocked": false,
"borders": ["MMR", "IND"],
"area": 147570,
"demonyms": {
"eng": {
"f": "Bangladeshi",
"m": "Bangladeshi"
},
"fra": {
"f": "Bangladaise",
"m": "Bangladais"
}
},
"flag": "🇧🇩",
"maps": {
"googleMaps": "https://goo.gl/maps/op6gmLbHcvv6rLhH6",
"openStreetMaps": "https://www.openstreetmap.org/relation/184640"
},
"population": 164689383,
"gini": {
"2016": 32.4
},
"fifa": "BAN",
"car": {
"signs": ["BD"],
"side": "left"
},
"timezones": ["UTC+06:00"],
"continents": ["Asia"],
"flags": {
"png": "https://flagcdn.com/w320/bd.png",
"svg": "https://flagcdn.com/bd.svg",
"alt": "The flag of Bangladesh has a dark green field bearing a large red circle that is offset slightly towards the hoist side of center."
},
"coatOfArms": {
"png": "https://mainfacts.com/media/images/coats_of_arms/bd.png",
"svg": "https://mainfacts.com/media/images/coats_of_arms/bd.svg"
},
"startOfWeek": "sunday",
"capitalInfo": {
"latlng": [23.72, 90.4]
},
"postalCode": {
"format": "####",
"regex": "^(\\d{4})$"
}
}
]
```
## Contributors
We welcome contributions! If you'd like to contribute, please follow these guidelines:
- **Pull Requests:** Base your pull requests against the `main` branch.
- **Contributing Guide:** Adhere to the instructions in the [contributing guide](CONTRIBUTING.md).
- **Documentation Changes:** If your pull request includes changes to the documentation, ensure the README file is updated accordingly.
We appreciate your efforts to improve this project!
## License
This project is licensed under the terms of the MIT license.