Skip to main content
The @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.
Need data that updates without publishing a new package version, typo-tolerant search, or usage tracking? Pair these packages with the TypeScript SDK — a live API client for when you need that instead of (or alongside) a bundled snapshot. Its Migrating from the Local Packages section has a side-by-side comparison. Get a free 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

Supported locales: 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.
See the CLI page for the full command reference, including typo-tolerant fuzzy search and --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:
The counts above are from one release and are illustrative — they change every time the data is refreshed.

Comparing your package against the live API

The Get Data Version endpoint returns the same three fields for the data the API is serving. Compare sourceRelease, 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.
The package’s 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.