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

ghana-locations

v1.1.4

Published

Ghana regions and cities/towns data with validation helpers

Downloads

16

Readme

ghana-locations

Ghana's 16 regions and their cities/towns as structured data, with validation helpers and TypeScript support.

Features

  • 16 Regions: All current administrative regions of Ghana.
  • Cities & Towns: Comprehensive list of major cities and district capitals.
  • Validation: Built-in validation functions and optional integrations for zod and class-validator.
  • TypeScript: First-class TypeScript support with full type definitions.
  • Zero Dependencies: Pure data and utility functions (at runtime).
  • Dual Export: Supports both ESM and CommonJS.

Installation

npm install ghana-locations

Usage

Basic Usage

import { 
  getRegions, 
  getCities, 
  isValidRegion, 
  RegionName 
} from 'ghana-locations';

// Get all regions
const regions = getRegions();

// Get cities for a specific region
const accraCities = getCities(RegionName.GreaterAccra);

// Validate a region
const isValid = isValidRegion('Greater Accra'); // true

Search and Reverse Lookup

import { searchCities, findRegionByCity } from 'ghana-locations';

// Search for cities (case-insensitive)
const results = searchCities('accra');
// [{ region: "Greater Accra", city: "Accra" }]

// Find which region a city belongs to
const region = findRegionByCity('Kumasi');
// { name: "Ashanti", slug: "ashanti", cities: [...] }

Validation Integrations

Zod

import { ghanaRegionSchema, ghanaLocationSchema } from 'ghana-locations/zod';

ghanaRegionSchema.parse('Ashanti'); // OK
ghanaLocationSchema.parse({ region: 'Ashanti', city: 'Kumasi' }); // OK

class-validator

import { IsGhanaRegion, IsGhanaCity } from 'ghana-locations/class-validator';

class CreateAddressDto {
  @IsGhanaRegion()
  region: string;

  @IsGhanaCity('region')
  city: string;
}

API Reference

Constants

  • RegionName: Enum of all 16 region names.
  • RegionSlug: Enum of all 16 region slugs.
  • citiesByRegion: Map of region name to an array of cities.
  • regions: Array of all 16 region objects (name, slug, cities).

Functions

  • getRegions(): Returns all regions.
  • getCities(region): Returns cities for a region (accepts name or slug).
  • getRegion(identifier): Get a single region by name or slug.
  • isValidRegion(value): Check if a string is a valid region name or slug.
  • isValidCity(region, city): Check if a city belongs to a region.
  • isValidLocation({ region, city }): Validate a full location object.
  • findRegionByCity(city): Find which region a city belongs to.
  • searchCities(query): Case-insensitive search across all cities.

License

MIT