{"id":30515452,"url":"https://github.com/k-yle/get-region","last_synced_at":"2025-08-26T08:24:02.420Z","repository":{"id":302429812,"uuid":"976583972","full_name":"k-yle/get-region","owner":"k-yle","description":"🌐 Tiny package (\u003c400 bytes!) to get the user's country without calling any APIs, and without hardcoding any data.","archived":false,"fork":false,"pushed_at":"2025-05-02T11:23:25.000Z","size":56,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-04T04:00:03.552Z","etag":null,"topics":["country","intl","npm","region","timezones"],"latest_commit_sha":null,"homepage":"https://npm.im/get-region","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/k-yle.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-02T11:21:40.000Z","updated_at":"2025-05-02T11:25:17.000Z","dependencies_parsed_at":"2025-07-02T11:10:57.521Z","dependency_job_id":"13dd4bff-313b-42f2-b0fc-abb9f0621064","html_url":"https://github.com/k-yle/get-region","commit_stats":null,"previous_names":["k-yle/get-region"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/k-yle/get-region","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-yle%2Fget-region","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-yle%2Fget-region/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-yle%2Fget-region/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-yle%2Fget-region/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/k-yle","download_url":"https://codeload.github.com/k-yle/get-region/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/k-yle%2Fget-region/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272193734,"owners_count":24889718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["country","intl","npm","region","timezones"],"created_at":"2025-08-26T08:23:59.547Z","updated_at":"2025-08-26T08:24:02.413Z","avatar_url":"https://github.com/k-yle.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# get-region\n\n[![Build Status](https://github.com/k-yle/get-region/workflows/CI/badge.svg)](https://github.com/k-yle/get-region/actions)\n[![npm version](https://badge.fury.io/js/get-region.svg)](https://npm.im/get-region)\n[![npm](https://img.shields.io/npm/dt/get-region.svg)](https://npm.im/get-region)\n![npm bundle size](https://img.shields.io/bundlephobia/minzip/get-region)\n\n🌐 Tiny package (\u003c400 bytes!) to get the user's country without calling any APIs, and without hardcoding any data. Works in the browser and nodejs.\n\nIt uses the browser's native [`Intl` SDK](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions) to get the user's timezone, for example `Asia/Shanghai` or `Europe/Dublin`.\nA [different `Intl` SDK](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/getTimeZones) is used to convert the timezone to a country code, such as `CN` or `IE`.\n\n**This is not always reliable**; there are many cases where this approach fails.\nHowever, it can provide a quick solution.\nIt also only works in modern browsers that support these [`Intl` APIs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl).\n\n## Example\n\n```js\nimport region from 'get-region';\n\nconsole.log(region.country); // for example: 'US' if you're in the United States\n```\n\n## Install\n\n```sh\nnpm install get-region\n```\n\n## Questions\n\nThis library only gives you a country code.\n\n- _What if I need the country name?_ — use the native [`Intl.DisplayNames` class](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames)\n- _What if I need the latitude/longitude?_ — use a library like [country-coder](https://github.com/rapideditor/country-coder).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-yle%2Fget-region","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fk-yle%2Fget-region","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fk-yle%2Fget-region/lists"}