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

nepali-location

v1.0.2

Published

Complete Nepal location data with provinces, districts, and municipalities. Perfect for address forms and location-based applications.

Readme

Nepali Location Package

A complete Nepal location data library with provinces, districts, and municipalities. Perfect for building location-based applications, address forms, or handling geographical data in Nepal.

Features

  • Get provinces, districts, and municipalities in Nepal.
  • Retrieve municipalities based on districts, and districts based on provinces.
  • Location validation and search.
  • Hierarchical location data with provinces, districts, and municipalities.

Installation

You can install the package using npm or yarn:

Using npm:

npm install nepali-location
Using yarn:
bash
Copy code
yarn add nepali-location
Usage
Once installed, you can easily access location data and perform operations with the following functions.

Example Code:
1. Get Districts by Province
To get all districts for a specific province:

typescript
Copy code
import { getDistrictsByProvince } from 'nepali-location';

const districts = getDistrictsByProvince('Bagmati');
console.log(districts);
2. Get Municipalities by District
To get all municipalities in a specific district:

typescript
Copy code
import { getMunicipalitiesByDistrict } from 'nepali-location';

const municipalities = getMunicipalitiesByDistrict('Kathmandu');
console.log(municipalities);
3. Get Location Hierarchy
To get the full hierarchy (province, district, municipality) for a specific municipality:

typescript
Copy code
import { getLocationHierarchy } from 'nepali-location';

const locationHierarchy = getLocationHierarchy('Kathmandu');
console.log(locationHierarchy);
// Output: { province: 'Bagmati', district: 'Kathmandu', municipality: 'Kathmandu' }
4. Check if a Location Exists
To check if a province, district, or municipality exists:

typescript
Copy code
import { locationExists } from 'nepali-location';

const exists = locationExists('district', 'Kathmandu');
console.log(exists);  // Returns true or false
Data Structure Overview
Province-District Map: Mapping of provinces to their respective districts.

District-Municipality Map: Mapping of districts to their respective municipalities.

Example:
typescript
Copy code
const provinceDistrictMap = {
  bagmati: ['Kathmandu', 'Bhaktapur', 'Dhading'],
  gandaki: ['Gorkha', 'Kaski', 'Lamjung'],
  lumbini: ['Kapilvastu', 'Rupandehi', 'Arghakhanchi']
};

const districtMunicipalityMap = {
  kathmandu: ['Kathmandu', 'Kirtipur', 'Shankharapur'],
  bhaktapur: ['Bhaktapur', 'Madhyapur Thimi', 'Changunarayan']
};
Contributing
Contributions are welcome! If you'd like to improve this library, feel free to fork the repository, submit issues, or open pull requests.

How to Contribute:
Fork the repository.

Create your branch (e.g., git checkout -b feature-name).

Make your changes and commit them (e.g., git commit -am 'Add new feature').

Push to your branch (e.g., git push origin feature-name).

Open a pull request.

License
This package is licensed under the MIT License.

React Integration Example
Here’s how you can integrate nepali-location in a React + TypeScript app:

1. Install Dependencies
bash
Copy code
npm install nepali-location
2. App Component Code Example
tsx
Copy code
import React, { useState } from "react";
import { getDistrictsByProvince, getMunicipalitiesByDistrict } from "nepali-location";

function App() {
  const [province, setProvince] = useState("");
  const [district, setDistrict] = useState("");
  const [municipality, setMunicipality] = useState("");

  const [districts, setDistricts] = useState<string[]>([]);
  const [municipalities, setMunicipalities] = useState<string[]>([]);

  const handleProvinceChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
    const selectedProvince = e.target.value;
    setProvince(selectedProvince);
    setDistricts(getDistrictsByProvince(selectedProvince));
    setMunicipality(""); // Reset municipality when province changes
  };

  const handleDistrictChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
    const selectedDistrict = e.target.value;
    setDistrict(selectedDistrict);
    setMunicipalities(getMunicipalitiesByDistrict(selectedDistrict));
  };

  return (
    <div className="App">
      <h1>Select Your Location</h1>

      {/* Province Dropdown */}
      <select value={province} onChange={handleProvinceChange}>
        <option value="">Select Province</option>
        <option value="Bagmati">Bagmati</option>
        <option value="Sudurpaschim">Sudurpaschim</option>
        <option value="Gandaki">Gandaki</option>
        <option value="Karnali">Karnali</option>
        <option value="Lumbini">Lumbini</option>
        <option value="Pradesh-1">Pradesh-1</option>
        <option value="Madhesh">Madhesh</option>
      </select>

      {/* District Dropdown */}
      {province && (
        <select value={district} onChange={handleDistrictChange}>
          <option value="">Select District</option>
          {districts.map((district, index) => (
            <option key={index} value={district}>{district}</option>
          ))}
        </select>
      )}

      {/* Municipality Dropdown */}
      {district && (
        <select value={municipality} onChange={(e) => setMunicipality(e.target.value)}>
          <option value="">Select Municipality</option>
          {municipalities.map((municipality, index) => (
            <option key={index} value={municipality}>{municipality}</option>
          ))}
        </select>
      )}
    </div>
  );
}

export default App;
This React component allows users to select a province, then a district, and finally a municipality. The nepali-location package is used to fetch the districts for a province and the municipalities for a district.

This README provides an easy-to-follow guide for users to install, use, and contribute to the library. It also includes a full example of integrating the package into a React application.