States, Provinces & Administrative Divisions
The states array contains 600+ administrative divisions across 20+ countries: US states, Canadian provinces, Australian states, Swiss cantons, Brazilian states, German Lรคnder, French regions, Spanish autonomous communities, Italian regions, Mexican states, Japanese prefectures, Indian states, Chinese provinces, and more.
Import
import {
states,
getStatesByCountry,
getStateByCode,
getStatesByType,
} from "arevdata";
import type { State, StateType } from "arevdata";
Data shape
interface State {
name: string; // "California"
code: string; // "CA" โ state/province abbreviation code
country: string; // "US" โ ISO 3166-1 alpha-2 country code
type: StateType; // "state" | "province" | "territory" | ...
}
type StateType =
| "state"
| "province"
| "territory"
| "autonomous region"
| "district"
| "department"
| "region"
| "county"
| "emirate"
| "canton";
Examples
All divisions for a country
import { getStatesByCountry } from "arevdata";
// United States
const usAll = getStatesByCountry("US");
console.log(usAll.length); // 50 states + DC + territories = 57
// Switzerland
const chAll = getStatesByCountry("CH");
console.log(chAll.length); // 26 cantons
// Japan
const jpAll = getStatesByCountry("JP");
console.log(jpAll.length); // 47 prefectures
Look up a specific division by code
import { getStateByCode } from "arevdata";
getStateByCode("CA", "US");
// { name: "California", code: "CA", country: "US", type: "state" }
getStateByCode("ON", "CA");
// { name: "Ontario", code: "ON", country: "CA", type: "province" }
getStateByCode("ZZ", "US"); // undefined
Filter by division type
import { getStatesByType } from "arevdata";
// All provinces (CA, AU, ...)
const provinces = getStatesByType("province");
// All cantons (Switzerland)
const cantons = getStatesByType("canton");
cantons.every(c => c.country === "CH"); // true
cantons.length; // 26
// All territories
const territories = getStatesByType("territory");
territories.map(t => `${t.name} (${t.country})`);
// ["Australian Capital Territory (AU)", "Northwest Territories (CA)", ...]
Build a state selector that changes with the selected country
import { getStatesByCountry } from "arevdata";
function getStateOptions(countryCode: string) {
const divisions = getStatesByCountry(countryCode);
if (divisions.length === 0) return null; // no division data for this country
return divisions.map(s => ({
value: s.code,
label: s.name,
}));
}
getStateOptions("US");
// [{ value: "AL", label: "Alabama" }, { value: "AK", label: "Alaska" }, ...]
getStateOptions("CH");
// [{ value: "ZH", label: "Zurich" }, { value: "BE", label: "Bern" }, ...]
Country coverage
| Country | Type | Count |
|---|---|---|
| ๐บ๐ธ United States | states + DC + territories | 57 |
| ๐จ๐ฆ Canada | provinces + territories | 13 |
| ๐ฆ๐บ Australia | states + territories | 8 |
| ๐ง๐ท Brazil | states + DF | 27 |
| ๐ฉ๐ช Germany | Lรคnder | 16 |
| ๐ซ๐ท France | regions + overseas | 18 |
| ๐ช๐ธ Spain | autonomous communities | 17 |
| ๐ฎ๐น Italy | regions | 20 |
| ๐ฒ๐ฝ Mexico | states + CDMX | 32 |
| ๐ฎ๐ณ India | states + union territories | 36 |
| ๐จ๐ณ China | provinces + autonomous regions + municipalities | 33 |
| ๐ฏ๐ต Japan | prefectures | 47 |
| ๐จ๐ญ Switzerland | cantons | 26 |
| ๐ท๐บ Russia | federal subjects (8 major regions + Moscow) | 9 |
| ๐ฆ๐ช UAE | emirates | 7 |
| ๐ณ๐ด Norway | counties | 15 |
| ๐ต๐น Portugal | districts | 18 |
| ๐ณ๐ฑ Netherlands | provinces | 12 |
| ๐ง๐ช Belgium | provinces | 10 |
| ๐ธ๐ช Sweden | counties | 21 |