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

vietnam-divisions-js

v3.0.0

Published

Vietnam administrative divisions library. Supports both legacy (63 provinces, 3 levels) and new system per Resolution 202/2025/QH15 (34 provinces, 2 levels) with migration utilities.

Readme

Vietnam Divisions JS

Thư viện JavaScript/TypeScript cung cấp dữ liệu hành chính Việt Nam. Hỗ trợ cả hệ thống cũ (63 tỉnh, 3 cấp) và hệ thống mới theo Nghị quyết 202/2025/QH15 (34 tỉnh, 2 cấp).

Đã đổi tên từ vietnam-provinces-js sang vietnam-divisions-js kể từ v3.0.0.

npm install vietnam-divisions-js

Sử dụng

Dữ liệu cũ (v2) — 63 tỉnh, 3 cấp: Tỉnh → Quận/Huyện → Xã/Phường

import { Provinces, Districts, Communes } from 'vietnam-divisions-js';

const provinces = await Provinces.getAllProvince();          // 63 tỉnh
const districts = await Districts.getAllDistricts();          // 696 quận/huyện
const communes  = await Communes.getAllCommunes();            // 10,051 xã/phường

const hanoi    = await Provinces.searchProvinceByName('Hà Nội');
const district = await Districts.getDistrictById('001');
const commune  = await Communes.getCommuneById('00001');

Dữ liệu mới (v3) — 34 tỉnh, 2 cấp: Tỉnh/TP → Xã/Phường

Theo NQ 202/2025/QH15, hệ thống hành chính mới bỏ cấp quận/huyện.

import { v3 } from 'vietnam-divisions-js';

const provinces = await v3.getAllProvinces();                 // 34 tỉnh
const hcm       = await v3.getProvinceByCode('HCM');         // tìm theo mã 3 ký tự
const communes  = await v3.getCommunesByProvinceId('79');     // xã/phường thuộc tỉnh
const search    = await v3.searchProvinceByName('Đà Nẵng');

Migration — Chuyển đổi dữ liệu cũ ↔ mới

import { Migration } from 'vietnam-divisions-js';

// Chuyển mã xã cũ → mới
const mapped = await Migration.migrateWardCode('26881');

// Tra cứu tỉnh sáp nhập
const merged = await Migration.getMergedProvince('02');
// → { oldProvinceId: '02', oldProvinceName: 'Hà Giang', newProvinceId: '08', newProvinceName: 'Tuyên Quang' }

// Batch migrate
const results = await Migration.batchMigrateWardCodes(['26881', '00004']);

// Xem toàn bộ danh sách sáp nhập
const allMerges = await Migration.getAllMergedProvinces();

Dùng cả v2 + v3 trong cùng 1 app

import { Provinces, v3, Migration } from 'vietnam-divisions-js';

// Hiển thị địa chỉ cũ từ database
const oldProvince = await Provinces.getProvinceById('02');     // Hà Giang

// Chuyển sang địa chỉ mới
const merged = await Migration.getMergedProvince('02');         // → Tuyên Quang
const newProvince = await v3.getProvinceById(merged.newProvinceId);

Tree-shaking — Import trực tiếp

import { getAllProvinces } from 'vietnam-divisions-js/v3';
import { migrateWardCode } from 'vietnam-divisions-js/migration';

Dữ liệu

| | v2 (cũ) | v3 (NQ 202/2025) | |---|---|---| | Tỉnh/TP | 63 | 34 | | Quận/Huyện | 696 | — (đã bỏ) | | Xã/Phường | 10,051 | 3,321 | | Ánh xạ cũ→mới | — | 10,977 |

License

MIT — tnmod