react-country-state-fields

The react-country-state-fields package wraps the VisitorAPI SDK into cascading country, state, and city form fields that auto-fill from the visitor’s IP location, so you don’t have to write the useState/useEffect wiring yourself. Use it as Material UI components, or headless with your own UI (Tailwind, Chakra, plain HTML).

Country, state, and city fields auto-filling from the visitor’s detected location

Source and issue tracker: github.com/visitorapi/react-country-state-fields

Full write-up with examples: react-country-state-fields: auto-detect and auto-fill location fields

Prefer to call the API yourself instead? See the VisitorAPI SDK docs.

Common use cases

  • Checkout auto-fill — automatically populate country and state fields at checkout using the visitor’s detected location