{"id":21238706,"url":"https://github.com/shahradelahi/react-geetest","last_synced_at":"2025-07-10T19:31:46.552Z","repository":{"id":148147531,"uuid":"619853217","full_name":"shahradelahi/react-geetest","owner":"shahradelahi","description":"React library for GeeTest captcha integration","archived":false,"fork":false,"pushed_at":"2024-01-13T09:29:48.000Z","size":205,"stargazers_count":58,"open_issues_count":0,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T20:29:24.485Z","etag":null,"topics":["geetest","geetest-captcha","react"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/react-geetest-v4","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/shahradelahi.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}},"created_at":"2023-03-27T14:46:47.000Z","updated_at":"2024-10-17T11:20:58.000Z","dependencies_parsed_at":"2023-12-03T18:38:54.287Z","dependency_job_id":null,"html_url":"https://github.com/shahradelahi/react-geetest","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Freact-geetest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Freact-geetest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Freact-geetest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shahradelahi%2Freact-geetest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shahradelahi","download_url":"https://codeload.github.com/shahradelahi/react-geetest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225653893,"owners_count":17502940,"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","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":["geetest","geetest-captcha","react"],"created_at":"2024-11-21T00:37:49.520Z","updated_at":"2024-11-21T00:37:50.211Z","avatar_url":"https://github.com/shahradelahi.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GeeTest integration for React\n\nA very simple React component to integrate [GeeTest captcha](https://docs.geetest.com/BehaviorVerification/overview/start/).\n\n## Installation\n\n```bash\nnpm install react-geetest-v4\n```\n\n## Usage\n\n#### Normal practice\n\n```tsx\nimport React from 'react';\nimport GeeTest, { GeeTestRef } from 'react-geetest-v4';\n\nexport default function Home(): JSX.Element {\n  const captchaRef = React.useRef\u003cGeeTestRef | null\u003e(null); // Access: showCaptcha, reset, ...\n  return (\n    \u003cdiv\u003e\n      \u003cGeeTest\n        captchaId={'your captcha id'}\n        containerId={'geetest-captcha'} // Optional\n        onSuccess={(result) =\u003e console.log('success. result: ', result)}\n        onReady={() =\u003e console.log('ready')}\n      /\u003e\n      \u003cbr /\u003e\n      \u003cGeeTest\n        ref={captchaRef}\n        captchaId={'your captcha id'}\n        product={'bind'}\n        onSuccess={() =\u003e console.log('success')}\n      \u003e\n        \u003cbutton\u003eSubmit\u003c/button\u003e\n      \u003c/GeeTest\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n#### Using hooks\n\n```tsx\nimport React from 'react';\nimport { useGeeTest } from 'react-geetest-v4';\n\nexport default function Home(): JSX.Element {\n  const { captcha, state } = useGeeTest('your captcha id', {\n    product: 'bind',\n    protocol: 'https://',\n    containerId: 'geetest-captcha',\n  });\n\n  const onClick = () =\u003e {\n    captcha?.showCaptcha();\n  };\n\n  return (\n    \u003cdiv\u003e\n      \u003cbutton onClick={onClick}\u003eSubmit\u003c/button\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n#### Server validation\n\nOn this example we're using Next.JS handlers, but you can use any other framework.\n\n```typescript\nimport type { NextApiRequest, NextApiResponse } from 'next';\nimport { validateCaptcha, generateSignToken } from 'react-geetest-v4';\n\nconst CAPTCHA_ID = '647f5ed2ed8acb4be36784e01556bb71';\nconst CAPTCHA_KEY = 'b09a7aafbfd83f73b35a9b530d0337bf';\n\nexport default async function handler(req: NextApiRequest, res: NextApiResponse) {\n  const { captcha_output, gen_time, lot_number, pass_token } = req.body;\n  if (!captcha_output || !gen_time || !lot_number || !pass_token) {\n    return res.status(400).json({ error: 'Missing required parameters' });\n  }\n\n  const { result } = await validateCaptcha({\n    captcha_id: CAPTCHA_ID,\n    lot_number,\n    captcha_output,\n    pass_token,\n    gen_time,\n    sign_token: generateSignToken(lot_number, CAPTCHA_KEY),\n  });\n\n  return res.status(200).json({ ok: result === 'success' });\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Freact-geetest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshahradelahi%2Freact-geetest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshahradelahi%2Freact-geetest/lists"}