{"id":26712336,"url":"https://github.com/u4aew/react-webauthn","last_synced_at":"2025-04-13T21:06:54.755Z","repository":{"id":62308801,"uuid":"559526937","full_name":"u4aew/react-webauthn","owner":"u4aew","description":"React hook for webAuthn","archived":false,"fork":false,"pushed_at":"2024-11-03T09:52:58.000Z","size":9940,"stargazers_count":30,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T21:06:45.650Z","etag":null,"topics":["hook","react","webauthn"],"latest_commit_sha":null,"homepage":"https://webauthn.fancyapp.site","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/u4aew.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}},"created_at":"2022-10-30T11:55:35.000Z","updated_at":"2025-03-03T10:41:54.000Z","dependencies_parsed_at":"2023-12-02T16:40:40.946Z","dependency_job_id":null,"html_url":"https://github.com/u4aew/react-webauthn","commit_stats":{"total_commits":17,"total_committers":1,"mean_commits":17.0,"dds":0.0,"last_synced_commit":"a391c2e255d785e686e9ee1a68a77609207094e4"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-webauthn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-webauthn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-webauthn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/u4aew%2Freact-webauthn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/u4aew","download_url":"https://codeload.github.com/u4aew/react-webauthn/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782269,"owners_count":21160717,"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":["hook","react","webauthn"],"created_at":"2025-03-27T11:23:58.962Z","updated_at":"2025-04-13T21:06:54.730Z","avatar_url":"https://github.com/u4aew.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://badge.fury.io/js/react-hook-webauthn.svg)](https://badge.fury.io/js/react-hook-webauthn)\n# React-hook-webauthn\nSimple Hook for react, serverless use of webAuthn\n\n![demo](./img/demo.gif)\n\n## Installing as a package\n\n```\nnpm i react-hook-webauthn\n```\n\n## Usage\nA detailed setup process can be read in this [article](https://dev.to/u4aew/adding-webauthnto-the-web-application-59gp).\n```js\nimport React, { useCallback, useState } from 'react';\nimport {useWebAuthn} from 'react-hook-webauthn'\nimport './App.css';\n\nconst rpOptions = {\n  rpId: 'localhost',\n  rpName: 'my super app'\n}\n\nfunction App() {\n  const [login, setLogin] = useState('')\n  const {getCredential, getAssertion} = useWebAuthn(rpOptions)\n\n  const onChangeLogin = useCallback((e: any) =\u003e {\n    setLogin(e.target.value)\n  }, [])\n\n  const onRegister = useCallback(async  () =\u003e {\n    const credential = await getCredential({\n      challenge: 'stringFromServer',\n      userDisplayName: login,\n      userId: login,\n      userName: login\n    })\n    console.log(credential)\n  }, [getCredential, login])\n\n  const onAuth = useCallback(async () =\u003e {\n    const assertion =  await getAssertion({challenge: 'stringFromServer'})\n    console.log(assertion)\n  }, [getAssertion])\n\n  return (\n    \u003cdiv className=\"App\"\u003e\n      \u003cmain\u003e\n        \u003cdiv className=\"section\"\u003e\n          \u003cinput onInput={onChangeLogin} placeholder=\"login\" type=\"text\"/\u003e\n        \u003c/div\u003e\n         \u003cdiv className=\"section\"\u003e\n           \u003cbutton onClick={onRegister} type=\"button\"\u003eregister\u003c/button\u003e\n         \u003c/div\u003e\n        \u003cdiv className=\"del\"/\u003e\n        \u003cdiv className=\"section\"\u003e\n          \u003cbutton onClick={onAuth} type=\"button\"\u003eauth\u003c/button\u003e\n        \u003c/div\u003e\n      \u003c/main\u003e\n    \u003c/div\u003e\n  );\n}\n\nexport default App;\n```\n\n## Options\n| name            | type   | required |\n|-----------------|--------|----------|\n| rpName          | string | true     |\n| rpId            | string | true     |\n| userName        | string | true     |\n| userDisplayName | string | true     |\n| challenge       | string | true     |\n| credentialOpt   | object | false    |\n| assertionOpt    | object | false    |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fu4aew%2Freact-webauthn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fu4aew%2Freact-webauthn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fu4aew%2Freact-webauthn/lists"}