Skip to main content
The @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.
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

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:
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.