@countrystatecity monorepo publishes offline data packages, a CLI, and the live API SDK. Bundled data packages work locally without an API key. countries-browser and geojson fetch snapshots from a CDN and need a network connection when loading; API-backed CLI commands and the SDK require an API key.
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
Data packages contain versioned snapshots of the countries-states-cities-database. Updating your application requires installing a newer published package version; release timing and package versions vary. The API SDK and CLI have their own releases. 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.