getCountry()function

getCountry(value: unknown = "detect"): Country | undefined
ParamType
valueunknown
The country code to parse, or "detect" to read it from the browser. Defaults to "detect". Defaults to "detect"
Return
Country | undefined
The matching Country code, or undefined if it could not be resolved.

Parse a country string, or detect a browser country from navigator.language.

  • When value is "detect", reads the last two characters of navigator.language (if available).
  • Matching is case-insensitive; the value is uppercased before lookup.

Examples

getCountry("gb") // "GB"