Skip to Content
Version 0.0.1 is released 🎉

States Data

Get All States

This gives you an array of all states.

states.ts
import { States } from 'countries-geo'; console.log(States.getAll); // Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])

By default this is sorted by name.

Get All States sorted by isoCode

This gives you an array of all states specifically sorted by isoCode.

states.ts
import { States } from 'countries-geo'; console.log(States.sortByIsoCode); // Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])

By default this is sorted by iso.

Get States by Country

This gives you an array of all states filtered by a Country isoCode.

states.ts
import { States } from 'countries-geo'; console.log(States.getByCountry('GH')); // Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])

By default this is sorted by name.

Get States by Continent

This gives you an array of all states filtered by a Continent isoCode.

states.ts
import { States } from 'countries-geo'; console.log(States.getByContinent('AF')); // Logs all States (e.g., [{ iso: "GH-AA", name: "Greater Accra" }, ...])

By default this is sorted by name.

Last updated on