<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abi thanush</title>
    <description>The latest articles on DEV Community by Abi thanush (@abi_thanush_531624f2f0753).</description>
    <link>https://dev.to/abi_thanush_531624f2f0753</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4069954%2Fc300c7d7-fdf9-4901-b4ce-a1782b8440f7.jpg</url>
      <title>DEV Community: Abi thanush</title>
      <link>https://dev.to/abi_thanush_531624f2f0753</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abi_thanush_531624f2f0753"/>
    <language>en</language>
    <item>
      <title>Why I Built a New NPM Package for Accurate Country, State, and District Data</title>
      <dc:creator>Abi thanush</dc:creator>
      <pubDate>Sun, 09 Aug 2026 14:19:39 +0000</pubDate>
      <link>https://dev.to/abi_thanush_531624f2f0753/why-i-built-a-new-npm-package-for-accurate-country-state-and-district-data-41il</link>
      <guid>https://dev.to/abi_thanush_531624f2f0753/why-i-built-a-new-npm-package-for-accurate-country-state-and-district-data-41il</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwrg67zwfndagf21lkmc9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwrg67zwfndagf21lkmc9.png" alt=" " width="800" height="533"&gt;&lt;/a&gt;Geographic dropdowns (Country ➔ State ➔ District) are a standard feature in almost every web application. &lt;/p&gt;

&lt;p&gt;Most developers turn to popular libraries like &lt;code&gt;country-state-city&lt;/code&gt; (which has over 15k stars) to get this data. However, while working on a recent project, I realized how inaccurate and bloated existing solutions are.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem: Sri Lanka Has 9 Provinces, Not 15+
&lt;/h2&gt;

&lt;p&gt;In popular libraries, when you query subdivisions for Sri Lanka, it returns 15+ random entities that are mixtures of old boundaries and local municipalities instead of the official &lt;strong&gt;9 provinces&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This inaccuracy is common across many countries. On top of that, these packages load massive 8MB+ JSON databases into memory at once, which slows down client-side applications.&lt;/p&gt;

&lt;p&gt;To solve this, I built and published: &lt;strong&gt;&lt;a href="https://www.npmjs.com/package/world-country-state-district" rel="noopener noreferrer"&gt;world-country-state-district&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Makes This Package Different?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Verified Administrative Accuracy
&lt;/h3&gt;

&lt;p&gt;I verified the data against official government directories. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Sri Lanka&lt;/strong&gt;: Exactly 9 provinces and 25 districts.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;India&lt;/strong&gt;: Exactly 28 states, 8 Union Territories, and 780 districts.&lt;/li&gt;
&lt;li&gt;  Every data file has passed structural checks and contains source links.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. On-Demand Lazy Loading (Under 68kB unpacked!)
&lt;/h3&gt;

&lt;p&gt;Instead of loading all countries at once, this library loads country data files dynamically. Calling &lt;code&gt;getSubdivisions('LK')&lt;/code&gt; reads only the tiny 2KB &lt;code&gt;LK.json&lt;/code&gt; file and caches it. The rest of the world data remains untouched on disk.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Flexible Hierarchy
&lt;/h3&gt;

&lt;p&gt;It respects that different countries have different admin levels rather than forcing a standard &lt;code&gt;State ➔ City&lt;/code&gt; model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Sri Lanka: &lt;code&gt;Province ➔ District&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  India: &lt;code&gt;State ➔ District&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;  UK: &lt;code&gt;Country ➔ County/Area&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;

&lt;p&gt;You can install it in any Node.js project:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
bash
npm install world-country-state-district

const geo = require('world-country-state-district');

// Get provinces
const provinces = geo.getSubdivisions('LK');

// Get districts inside Western Province
const districts = geo.getSubdivisionChildren('LK', 'Western Province');



![ ](https://dev-to-uploads.s3.us-east-2.amazonaws.com/uploads/articles/3kftahg42u05sgtknqc5.png)The package is fully open-source and ready to use:

📦 NPM Registry: world-country-state-district
💻 GitHub Repo: abiA2711/world-country-state-district
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
