Skip to the content

Kuni国

Look up countries, codes, names and subdivisions, load country data on demand and mount a native country card.

Kuni (国) is Japanese for a country. About the name

Contents

How-to

Load one country at a time

Use the original static paths or on-demand loaders.

Use the native API

import { loadSubdivisions } from "@johnmorrisdotca/kuni/load";
import prefectures from "@johnmorrisdotca/kuni/subdivisions/jp";
console.log((await loadSubdivisions("JP"))?.length,prefectures.length,prefectures[0].code);
console.log(await loadSubdivisions("XX"));
47 47 JP-01
null

A fixed country import points to the same existing built file as the retained wildcard path. Default and named SUBDIVISIONS exports refer to the same native list. On-demand loading uses one country module; a host bundler can make its own chunk. This is module loading, not a live geographic-data API. Unsupported codes return null; valid countries with no subdivisions return an empty list.

Read subdivision facts separately

import { loadSubdivisionFacts } from "@johnmorrisdotca/kuni/subdivision-facts";
import facts from "@johnmorrisdotca/kuni/subdivision-facts/jp";
console.log((await loadSubdivisionFacts("JP"))?.length,facts[0].code);
47 JP-01

Keep the subdivision name record distinct from its facts. The catalogue names all 400 existing fixed resource paths. Wildcard imports remain available with their unchanged ESM/CommonJS targets.

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kuni 1.4.0.