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

ng-locations

v1.0.0

Published

A zero-dependency TypeScript library for querying Nigerian states, LGAs, airports, universities, land mass, and geo-political zones.

Downloads

137

Readme

ng-locations

A zero-dependency TypeScript library for querying Nigerian states, LGAs, universities, airports, land mass, and geo-political zones. Works anywhere JavaScript runs — Node.js, React, Vue, Svelte, or plain JS.

npm version license TypeScript


Install

npm install ng-locations
# or
yarn add ng-locations
# or
pnpm add ng-locations

Key Features

  • Search by name or ID — pass a state name like "Lagos" or its UUID interchangeably
  • Input sanitization — leading/trailing spaces and casing are handled automatically, so " lagos ", "LAGOS", and "Lagos" all work
  • Full TypeScript support — all functions and return types are fully typed
  • Zero dependencies — no external packages required
  • Framework-agnostic — works in Node.js, React, Vue, Svelte, or any JS environment
  • Dual package — ships as both ESM and CommonJS

Usage

Lookup by name or ID

All functions that take a state or LGA identifier accept either the name or the UUID. Input is sanitized internally (trimmed and lowercased), so any casing or extra spaces work fine.

import { getStateCapital } from "ng-locations";

getStateCapital("Lagos")                              // "Ikeja"
getStateCapital("lagos")                              // "Ikeja"
getStateCapital("  LAGOS  ")                          // "Ikeja"
getStateCapital("3ac495b8-4196-4126-bf9e-bb8d43a0355d") // "Yola"

Get all states info

import { getAllStatesInfo } from "ng-locations";

getAllStatesInfo();
// => [
//   {
//     name: "Abia",
//     capital: "Umuahia",
//     id: "2e14a7ed-349a-44f6-9e12-abfec3e5f6ed",
//     lgas: [...],
//     land_mass: "6,320 km²",
//     universities: [...],
//     airports: [],
//     geopolitical_zone: "South East",
//   },
//   ...
// ]

Get all states (name + ID only)

import { getAllStates } from "ng-locations";

getAllStates();
// => [
//   { name: "Abia", id: "2e14a7ed-349a-44f6-9e12-abfec3e5f6ed" },
//   { name: "Adamawa", id: "3ac495b8-4196-4126-bf9e-bb8d43a0355d" },
//   ...
// ]

Get full info for a single state

import { getStateInfo } from "ng-locations";

getStateInfo("Lagos");
// => { name: "Lagos", capital: "Ikeja", id: "...", lgas: [...], ... }

getStateInfo("not-a-state");
// => "State not found. Check the ID or name passed."

Get a state (name + ID only)

import { getState } from "ng-locations";

getState("Lagos");
// => { name: "Lagos", id: "..." }

Get capital of a state

import { getStateCapital } from "ng-locations";

getStateCapital("Ogun"); // => "Abeokuta"

Get land mass of a state

import { getStateLandMass } from "ng-locations";

getStateLandMass("Rivers"); // => "11,077 km²"

Get geo-political zone of a state

import { getStateGeoPoliticalZone } from "ng-locations";

getStateGeoPoliticalZone("Kano"); // => "North West"

Get all LGAs in a state

import { getStateLGAs } from "ng-locations";

getStateLGAs("Abia");
// => [
//   { name: "Aba South", id: "4c840cb1-..." },
//   { name: "Arochukwu", id: "f46f5f01-..." },
//   ...
// ]

Get a single LGA

import { getLGA } from "ng-locations";

// By state name + LGA name
getLGA("Abia", "Aba South");
// => { name: "Aba South", id: "4c840cb1-8f58-40d3-9aff-5a3b77fdba71" }

// By state ID + LGA ID
getLGA("2e14a7ed-...", "4c840cb1-...");
// => { name: "Aba South", id: "4c840cb1-..." }

// Mixed is also fine
getLGA("Abia", "4c840cb1-...");
// => { name: "Aba South", id: "4c840cb1-..." }

Get all universities in a state

import { getStateUniversities } from "ng-locations";

getStateUniversities("Abia");
// => [
//   { name: "Abia State University", location: "Uturu", type: "State" },
//   { name: "Michael Okpara University of Agriculture", location: "Umudike", type: "Federal" },
// ]

Get all airports in a state

import { getStateAirports } from "ng-locations";

getStateAirports("Lagos");
// => [
//   { name: "Murtala Muhammed International Airport", IATA_code: "LOS", type: "International" },
// ]

API Reference

All functions return the result directly or a string error message when the lookup fails.

| Function | Parameters | Returns | |---|---|---| | getAllStatesInfo() | — | TStateInfo[] | | getAllStates() | — | TState[] | | getStateInfo(idOrName) | string | TStateInfo \| string | | getState(idOrName) | string | TState \| string | | getStateCapital(idOrName) | string | string | | getStateLandMass(idOrName) | string | string | | getStateGeoPoliticalZone(idOrName) | string | string | | getStateLGAs(idOrName) | string | TLGA[] \| string | | getLGA(stateIdOrName, lgaIdOrName) | string, string | TLGA \| string | | getStateUniversities(idOrName) | string | TUniversity[] \| string | | getStateAirports(idOrName) | string | TAirport[] \| string |

Types

type TStateInfo = {
  name: string;
  capital: string;
  id: string;
  lgas: TLGA[];
  land_mass: string;
  universities: TUniversity[];
  airports: TAirport[];
  geopolitical_zone: string;
};

type TState = { name: string; id: string };

type TLGA = { name: string; id: string };

type TUniversity = { name: string; location: string; type: string };

type TAirport = { name: string; IATA_code: string; type: string };

CommonJS usage

const { getAllStates, getStateCapital } = require("ng-locations");

License

MIT © Muiz Haruna