{"id":51101506,"url":"https://github.com/phucbm/react-hanzi-input","last_synced_at":"2026-06-24T11:01:18.921Z","repository":{"id":354313804,"uuid":"1223079326","full_name":"phucbm/react-hanzi-input","owner":"phucbm","description":"Chinese handwriting input component for React — canvas pad, stroke capture, and candidate picker powered by Google IME.","archived":false,"fork":false,"pushed_at":"2026-04-28T03:50:14.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-28T04:13:50.515Z","etag":null,"topics":["hanzi","hanzi-writer"],"latest_commit_sha":null,"homepage":"https://phucbm.github.io/react-hanzi-input/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phucbm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-28T01:47:46.000Z","updated_at":"2026-04-28T03:50:18.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/phucbm/react-hanzi-input","commit_stats":null,"previous_names":["phucbm/react-hanzi-input"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/phucbm/react-hanzi-input","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phucbm%2Freact-hanzi-input","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phucbm%2Freact-hanzi-input/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phucbm%2Freact-hanzi-input/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phucbm%2Freact-hanzi-input/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phucbm","download_url":"https://codeload.github.com/phucbm/react-hanzi-input/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phucbm%2Freact-hanzi-input/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34728928,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"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":["hanzi","hanzi-writer"],"created_at":"2026-06-24T11:01:18.419Z","updated_at":"2026-06-24T11:01:18.915Z","avatar_url":"https://github.com/phucbm.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-hanzi-input\n\n\n\n[![npm version](https://img.shields.io/npm/v/react-hanzi-input?style=flat-square)](https://www.npmjs.com/package/react-hanzi-input)\n[![license](https://img.shields.io/npm/l/react-hanzi-input?style=flat-square)](LICENSE)\n\nChinese handwriting input component for React — canvas pad, stroke capture, and candidate picker powered by Google IME.\n\n**[Live Demo](https://phucbm.github.io/react-hanzi-input)**\n\n\u003cimg width=\"1624\" height=\"970\" alt=\"web-demo\" src=\"https://github.com/user-attachments/assets/a115d5b8-87ca-4687-be7b-8a171f96c4ff\" /\u003e\n\n\n## Two ways to use\n\n| | npm package | Registry (shadcn-style) |\n|---|---|---|\n| Install | `pnpm add react-hanzi-input` | `npx shadcn@latest add \u003curl\u003e` |\n| Editable | No — import only | **Yes** — files copied to your project |\n| Updates | `pnpm update` | Manual (you own the code) |\n| Best for | Quick integration | Deep customization |\n\n---\n\n## Option A — npm package\n\n```sh\npnpm add react-hanzi-input\n```\n\n### Quick start\n\n#### 1. Add the API proxy route (Next.js App Router)\n\n```ts\n// app/api/handwriting/route.ts\nimport { createHandwritingRoute } from 'react-hanzi-input'\nexport const { POST } = createHandwritingRoute()\n```\n\n#### 2. Use the component\n\n```tsx\nimport { HanziInput } from 'react-hanzi-input'\n\nexport default function Page() {\n  const [text, setText] = useState('')\n  return (\n    \u003cHanziInput\n      proxyUrl=\"/api/handwriting\"\n      onSelect={(char) =\u003e setText(prev =\u003e prev + char)}\n    /\u003e\n  )\n}\n```\n\n---\n\n## Option B — Registry (copy to edit)\n\nCopy the source files directly into your project so you can freely customize every detail — styles, markup, behavior.\n\n### Full widget (`HanziInput` + `HanziPad` + recognize logic)\n\n```sh\nnpx shadcn@latest add https://phucbm.github.io/react-hanzi-input/r/hanzi-input.json\n```\n\nFiles land in `components/hanzi/`:\n\n```\ncomponents/hanzi/\n  HanziInput.tsx   ← main component\n  HanziPad.tsx     ← canvas pad\n  recognize.ts     ← Google IME API util\n  types.ts         ← TypeScript types\n```\n\n### Canvas only (`HanziPad`)\n\n```sh\nnpx shadcn@latest add https://phucbm.github.io/react-hanzi-input/r/hanzi-pad.json\n```\n\nFiles land in `components/hanzi/`:\n\n```\ncomponents/hanzi/\n  HanziPad.tsx\n  types.ts\n```\n\n### After copying\n\nYou still need the API proxy route — add it once to your app:\n\n```ts\n// app/api/handwriting/route.ts\nimport { createHandwritingRoute } from 'react-hanzi-input'\nexport const { POST } = createHandwritingRoute()\n```\n\nSince `recognize.ts` is already in your project, you can call `recognizeDirect()` server-side and skip the npm package entirely.\n\n---\n\n## API\n\n### `\u003cHanziInput\u003e`\n\n| Prop | Type | Default | Description |\n|------|------|---------|-------------|\n| `onSelect` | `(char: string) =\u003e void` | required | Called when user picks a candidate |\n| `proxyUrl` | `string` | required | Your API proxy URL |\n| `language` | `string` | `'zh-CN'` | IME language code |\n| `limit` | `number` | `8` | Max candidates |\n| `width` | `number` | `280` | Canvas width |\n| `height` | `number` | `280` | Canvas height |\n| `showUndo` | `boolean` | `true` | Show undo button |\n| `showClear` | `boolean` | `true` | Show clear button |\n| `className` | `string` | — | Wrapper class |\n\n### `\u003cHanziPad\u003e` (ref-based)\n\nLow-level canvas component. Exposes `getStrokes()`, `clear()`, `undo()`, `toDataURL()` via ref.\n\n### `recognizeDirect(strokes, options)`\n\nCall the Google IME API directly — useful in demos or server contexts.\n\n### `recognize(strokes, options)`\n\nCall via your proxy URL (avoids CORS in browser).\n\n### `createHandwritingRoute()`\n\nReturns a `{ POST }` handler compatible with Next.js App Router and any Web Fetch API handler.\n\n## Credits\n\nInspired by [icelam/chinese-handwriting-recognition](https://github.com/icelam/chinese-handwriting-recognition).\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphucbm%2Freact-hanzi-input","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphucbm%2Freact-hanzi-input","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphucbm%2Freact-hanzi-input/lists"}