{"id":16594625,"url":"https://github.com/antonybudianto/react-ua","last_synced_at":"2025-03-21T13:31:59.715Z","repository":{"id":33778300,"uuid":"159928508","full_name":"antonybudianto/react-ua","owner":"antonybudianto","description":"📱React User Agent Component, Hook, and HOC. SSR-ready, full UT, using new React Context and Hooks API","archived":false,"fork":false,"pushed_at":"2023-01-03T01:46:14.000Z","size":372,"stargazers_count":22,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T12:06:04.444Z","etag":null,"topics":["hooks","react","reactjs","ssr","user-agent","user-agent-parser"],"latest_commit_sha":null,"homepage":"","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/antonybudianto.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}},"created_at":"2018-12-01T09:23:06.000Z","updated_at":"2023-09-14T07:42:10.000Z","dependencies_parsed_at":"2023-01-15T02:30:46.076Z","dependency_job_id":null,"html_url":"https://github.com/antonybudianto/react-ua","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-ua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-ua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-ua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonybudianto%2Freact-ua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonybudianto","download_url":"https://codeload.github.com/antonybudianto/react-ua/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244806130,"owners_count":20513385,"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":["hooks","react","reactjs","ssr","user-agent","user-agent-parser"],"created_at":"2024-10-11T23:46:50.792Z","updated_at":"2025-03-21T13:31:59.397Z","avatar_url":"https://github.com/antonybudianto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-ua\n\n[![npm version](https://badge.fury.io/js/react-ua.svg)](https://badge.fury.io/js/react-ua)\n[![Build Status](https://travis-ci.org/antonybudianto/react-ua.svg?branch=master)](https://travis-ci.org/antonybudianto/react-ua)\n\n\u003cp align=\"center\"\u003e\n\u003cimg src=\"https://user-images.githubusercontent.com/7658554/210290544-85e3a809-c9e2-4a96-a5ce-349f15be907f.png\"\u003e\n\u003c/p\u003e\n\nReact User Agent Component and Provider, SSR-ready, using new React Context API\n\n## Requirement\n\n- React 16.8.0\n\n## Features\n\n- Wrapper for [ua-parser-js](https://github.com/faisalman/ua-parser-js)\n- Using new React [Hooks API](https://reactjs.org/docs/hooks-faq.html)\n- Using new React [Context API](https://reactjs.org/docs/context.html)\n- SSR-ready\n- Unit-tested\n\n\u003e Try it [live at StackBlitz](https://stackblitz.com/edit/demo-react-ua)\n\n```js\nimport React from 'react';\nimport { UserAgentProvider, useUserAgent } from 'react-ua';\n\nconst Comp = () =\u003e {\n  const ua = useUserAgent();\n  return \u003cdiv\u003eOS: {ua.os.name}\u003c/div\u003e;\n};\n\nconst App = () =\u003e (\n  \u003cUserAgentProvider\u003e\n    \u003cComp /\u003e\n  \u003c/UserAgentProvider\u003e\n);\n\nReactDOM.render(\u003cApp /\u003e, document.getElementById('#root'));\n\n// SSR\nconst el = (\n  \u003cUserAgentProvider value={request.headers['user-agent']}\u003e\n    \u003cComp /\u003e\n  \u003c/UserAgentProvider\u003e\n);\n\nReactDOMServer.renderToString(el);\n```\n\n## HOC (deprecated)\n\n```tsx\nimport { withUserAgent } from 'react-ua/hoc';\n\nconst CompWithHoc = withUserAgent(({ ua }) =\u003e \u003cdiv\u003eOS: {ua.os.name}\u003c/div\u003e);\n\nconst App = () =\u003e (\n  \u003cUserAgentProvider\u003e\n    \u003cCompWithHoc /\u003e\n  \u003c/UserAgentProvider\u003e\n);\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonybudianto%2Freact-ua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonybudianto%2Freact-ua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonybudianto%2Freact-ua/lists"}