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

nigeria-location-kit

v1.0.5

Published

A lightweight, Nigeria-only location utility library providing States and LGAs with headless core logic and optional React/React Native components.

Readme

nigeria-location-kit 🇳🇬

A lightweight, Nigeria-only location utility library providing States and LGAs with headless core logic and optional React/React Native components.

Features

  • Nigeria Only: Focused exclusively on the 36 states and FCT, including all local government areas (LGAs).
  • Extremely Simple: Flat API, no registry, no complex hierarchies, just direct access to the data you need.
  • Headless First: Extract the raw data or use our included unstyled React components.
  • Tree-shakeable & Small: Zero extra bloat.

Installation

npm install nigeria-location-kit

Core API (Vanilla JS/TS)

import {
  getStates,
  getLGAs,
  getStateByName,
  searchStates,
} from "nigeria-location-kit";

// Get all 36 states + FCT
const states = getStates();

// Get LGAs for a state by its ID, Name, or Code
const lgas = getLGAs("Lagos"); // Get LGAs for Lagos
const lgasById = getLGAs("NG-LAG"); // Also works!

// Quick search
const results = searchStates("Lagos"); // Returns Lagos

React Hooks & Components

1. Using Hooks directly

import { useState } from "react";
import { useStates, useLGAs } from "nigeria-location-kit/react";

function MyForm() {
  const [selectedState, setSelectedState] = useState("");
  
  // Get all states
  const states = useStates();
  
  // Automatically gets LGAs for the selected state (accepts ID or Name)
  const lgas = useLGAs(selectedState); 

  return (
    <div>
      <select onChange={(e) => setSelectedState(e.target.value)}>
        <option value="">Select State</option>
        {states.map(s => <option key={s.id} value={s.id}>{s.name}</option>)}
      </select>

      <select disabled={!selectedState}>
        <option value="">Select LGA</option>
        {lgas.map(l => <option key={l.id} value={l.id}>{l.name}</option>)}
      </select>
    </div>
  );
}

2. Using the Headless Component

Use the built-in React component to manage state automatically:

import { LocationPicker, useStates, useLGAs } from "nigeria-location-kit/react";

function MyApp() {
  return (
    <LocationPicker onChange={(value) => console.log("Selected:", value)} />
  );
}

Or build your own UI using the render props:

<LocationPicker>
  {({ states, lgas, selectState, selectLga }) => (
    <div>
      <select onChange={(e) => selectState(e.target.value)}>
        {states.map((s) => (
          <option value={s.id}>{s.name}</option>
        ))}
      </select>
      <select onChange={(e) => selectLga(e.target.value)}>
        {lgas.map((l) => (
          <option value={l.id}>{l.name}</option>
        ))}
      </select>
    </div>
  )}
</LocationPicker>

React Native

The package provides the exact same API surface, optimized for React Native primitives!

1. Hooks in React Native

You can import useStates and useLGAs from "nigeria-location-kit/react-native" and use them exactly the same way as shown in the web example above.

2. Headless Component in React Native

The React Native LocationPicker doesn't force any UI on you. Here is an example of how you can build a custom UI (e.g., using @react-native-picker/picker or custom modals):

import { View, Text } from "react-native";
import { Picker } from "@react-native-picker/picker";
import { LocationPicker } from "nigeria-location-kit/react-native";

export default function App() {
  return (
    <LocationPicker>
      {({ states, lgas, selectedState, selectedLga, selectState, selectLga }) => (
        <View style={{ padding: 20 }}>
          <Text>Select State:</Text>
          <Picker
            selectedValue={selectedState}
            onValueChange={(itemValue) => selectState(itemValue)}
          >
            <Picker.Item label="Select State" value="" />
            {states.map((s) => (
              <Picker.Item key={s.id} label={s.name} value={s.id} />
            ))}
          </Picker>

          <Text>Select LGA:</Text>
          <Picker
            selectedValue={selectedLga}
            onValueChange={(itemValue) => selectLga(itemValue)}
            enabled={!!selectedState}
          >
            <Picker.Item label="Select LGA" value="" />
            {lgas.map((l) => (
              <Picker.Item key={l.id} label={l.name} value={l.id} />
            ))}
          </Picker>
        </View>
      )}
    </LocationPicker>
  );
}