@countrystatecity monorepo publishes offline data packages, a CLI, and the live API SDK. The data packages work without an API key or network requests; the CLI and SDK call the REST API.
Packages
Installation
Install only the packages you need:Use
@countrystatecity/countries in Node.js, Next.js API routes, or Express. Use @countrystatecity/countries-browser in client-side React, Vue, or Svelte apps — it loads data via CDN instead of bundling it.Usage
Countries, States, and Cities
Timezones
Currencies
Translations
ar, br, de, es, fa, fr, hi, hr, it, ja, ko, nl, pl, pt, pt-BR, ru, tr, uk, zh-CN
CLI
Code generation (
csc generate) requires a Supporter plan or above. Run csc upgrade to view plans and pricing.--fields/--sort.
Data Updates
All packages update automatically every week via a CI pipeline that fetches the latest data from the countries-states-cities-database, runs tests, and publishes a patch release to npm. To get the latest data in your project, update the package:Checking your installed data version
Both@countrystatecity/countries and @countrystatecity/countries-browser export a getDataVersion() loader so you can confirm which release your installed package is bundling, without loading the full dataset:
Comparing your package against the live API
The Get Data Version endpoint returns the same three fields for the data the API is serving. ComparesourceRelease, not dataVersion.
Both sides build dataVersion from the same release tag, but they append different dates: the package uses the date the release was published, while the API uses the date that release was imported. Because the import happens after the release is published, the two strings usually differ by a day or more even when both sides hold exactly the same data. sourceRelease is identical on both sides, so it is the reliable parity key.
The API’s version metadata is cached and can trail a fresh import by about 5 minutes (about 5.5 minutes for the
X-CSC-Data-* response headers). If a comparison comes back out of sync right after a data refresh, retry a few minutes later before treating it as a real mismatch.recordCounts is narrower than the API’s — countries/states/cities only, no regions/subregions.
Source
GitHub Repository
View the monorepo source, open issues, or contribute.
npm Organization
Browse all published packages on npm.