naija-state-regions-by-osaze-agbi
v2.0.2
Published
Get Nigerian states and their regions/LGAs & neighborhoods easily
Maintainers
Readme
🇳🇬 naija-state-regions-by-osaze-agbi
Get all Nigerian states and easily retrieve their regions / LGAs / neighborhoods.
⚡ This package allows you to:
- Get all states in Nigeria
- Get regions (LGAs / neighborhoods) from a state
- Validate states and regions
- Use it easily in frontend or backend apps
📦 Installation
npm install naija-state-regions
yarn add naija-state-regions🚀 How to Use
Import
import {
getStates,
getRegionsByState,
isValidState,
isValidRegion,
getAll
} from "naija-state-regions";
//Get all states
const states = getStates();
console.log(states);
//Result:
[
"Abia",
"Akwa Ibom",
"Anambra",
"Bauchi",
"Bayelsa"
]
//Get regions from a state
const regions = getRegionsByState("Lagos");
console.log(regions);
//Result:
[
"Surulere Central",
"Yaba/Ebute Meta East",
"Victoria Island",
"Ojota",
"Ikoyi",
"Lekki"
]
//Validate a state
isValidState("Lagos"); // true
isValidState("Abuja"); // false
Validate a region inside a state
isValidRegion("Lagos", "Ikoyi"); // true
isValidRegion("Lagos", "Kano"); // false
Get full dataset
const data = getAll();
console.log(data);
//Result:
[
{
state: "Abia",
regions: ["Umunneochi", "Ugwunagbo"]
},
{
state: "Lagos",
regions: ["Surulere Central", "Yaba/Ebute Meta East"]
}
]📚 API
getStates()
Returns all Nigerian states.
getRegionsByState(state)
Returns all regions (LGAs / neighborhoods) for a given state.
isValidState(state)
Checks if a state exists.
isValidRegion(state, region)
Checks if a region belongs to a state.
getAll()
Returns the full dataset.💡 Use Cases
Form dropdowns (State → Region)
Address selection
Location filtering
Nigerian-based apps 🇳🇬⚠️ Notes
This package includes a mix of:
LGAs
Regions
Neighborhoods (especially for Lagos)🛠 Example (React)
import { useState } from "react";
import { getStates, getRegionsByState } from "naija-state-regions";
export default function App() {
const [state, setState] = useState("");
const states = getStates();
const regions = getRegionsByState(state);
return (
<>
<select onChange={(e) => setState(e.target.value)}>
<option>Select State</option>
{states.map((s) => (
<option key={s}>{s}</option>
))}
</select>
<select>
<option>Select Region</option>
{regions.map((r) => (
<option key={r}>{r}</option>
))}
</select>
</>
);
}📄 License
MIT