{"id":22240412,"url":"https://github.com/imgarylai/use-tw-zipcode","last_synced_at":"2025-10-25T09:13:44.796Z","repository":{"id":37049493,"uuid":"260490094","full_name":"imgarylai/use-tw-zipcode","owner":"imgarylai","description":"這是一個用於處理台灣郵遞區號的 React Hook，提供以下功能 台灣縣市和鄉鎮市區的選擇 自動計算郵遞區號 提供完整的縣市和鄉鎮市區資料","archived":false,"fork":false,"pushed_at":"2025-07-19T04:54:15.000Z","size":11833,"stargazers_count":15,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-19T09:48:05.431Z","etag":null,"topics":["hooks","react","reactjs","taiwan","typescript","zipcode"],"latest_commit_sha":null,"homepage":"https://use-tw-zipcode.vercel.app/","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/imgarylai.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-05-01T15:16:10.000Z","updated_at":"2025-07-19T04:54:18.000Z","dependencies_parsed_at":"2024-02-01T20:50:32.575Z","dependency_job_id":"e4d00d30-600d-4da8-bfe9-e5fe1d5939e3","html_url":"https://github.com/imgarylai/use-tw-zipcode","commit_stats":{"total_commits":327,"total_committers":6,"mean_commits":54.5,"dds":0.5015290519877675,"last_synced_commit":"e8c3a859281f44e37ee6fadb84de74515f19d701"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/imgarylai/use-tw-zipcode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgarylai%2Fuse-tw-zipcode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgarylai%2Fuse-tw-zipcode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgarylai%2Fuse-tw-zipcode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgarylai%2Fuse-tw-zipcode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/imgarylai","download_url":"https://codeload.github.com/imgarylai/use-tw-zipcode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/imgarylai%2Fuse-tw-zipcode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267446801,"owners_count":24088561,"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-07-27T02:00:11.917Z","response_time":82,"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":["hooks","react","reactjs","taiwan","typescript","zipcode"],"created_at":"2024-12-03T03:54:00.646Z","updated_at":"2025-10-25T09:13:44.713Z","avatar_url":"https://github.com/imgarylai.png","language":"TypeScript","readme":"# use-tw-zipcode\n\n[![npm](https://img.shields.io/npm/v/use-tw-zipcode)](https://www.npmjs.com/package/use-tw-zipcode)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)\n\n## Intro 簡介\n\n可以簡單地製作台灣縣市、行政區下拉式選單，並取得郵遞區號。本套件只處理邏輯的部分，所以可以很簡單地應用於各種 CSS 版型。\n\nTaiwanese zip code (3 digits) is determined by two factors: city and district. It is usually not necessary to ask users to fill in the zip code manually. It's more user-friendly if you can automatically capture the zip code once they select their city and district. A dropdown menu is commonly used for this scenario.\n\nThis library helps you create a user-friendly dropdown menu without any CSS/style framework dependency by using React hooks. You can find examples below. Let's build an excellent user interface together! 🙌🏻\n\n## Installation 安裝\n\n```bash\nnpm install use-tw-zipcode\n```\n\n## Example 範例\n\n```jsx\nimport React from 'react';\nimport { useTwZipCode, cities, districts } from 'use-tw-zipcode';\n\nexport default function App() {\n  const { city, district, zipCode, handleCityChange, handleDistrictChange } = useTwZipCode();\n  return (\n    \u003cdiv\u003e\n      \u003cdiv\u003e\n        {city}\n        {district}\n        {zipCode}\n      \u003c/div\u003e\n      \u003cselect onChange={(e) =\u003e handleCityChange(e.target.value)}\u003e\n        {cities.map((city, i) =\u003e {\n          return \u003coption key={i}\u003e{city}\u003c/option\u003e;\n        })}\n      \u003c/select\u003e\n      \u003cselect onChange={(e) =\u003e handleDistrictChange(e.target.value)}\u003e\n        {districts[city].map((district, i) =\u003e {\n          return \u003coption key={i}\u003e{district}\u003c/option\u003e;\n        })}\n      \u003c/select\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n## Live Demo\n\n[https://use-tw-zipcode.vercel.app/](https://use-tw-zipcode.vercel.app/)\n\nDemo Source Code: [https://github.com/imgarylai/use-tw-zipcode-vercel](https://github.com/imgarylai/use-tw-zipcode-vercel)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgarylai%2Fuse-tw-zipcode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimgarylai%2Fuse-tw-zipcode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimgarylai%2Fuse-tw-zipcode/lists"}