{"id":13450571,"url":"https://github.com/vardius/react-user-media","last_synced_at":"2025-03-21T23:33:42.322Z","repository":{"id":35114746,"uuid":"187561585","full_name":"vardius/react-user-media","owner":"vardius","description":"React wrapper for getUserMedia","archived":false,"fork":false,"pushed_at":"2022-12-10T15:20:32.000Z","size":584,"stargazers_count":22,"open_issues_count":12,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-14T06:09:02.197Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/vardius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["vardius"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2019-05-20T03:27:45.000Z","updated_at":"2024-10-04T16:42:21.000Z","dependencies_parsed_at":"2023-01-15T14:15:21.947Z","dependency_job_id":null,"html_url":"https://github.com/vardius/react-user-media","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/vardius%2Freact-user-media","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Freact-user-media/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Freact-user-media/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vardius%2Freact-user-media/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vardius","download_url":"https://codeload.github.com/vardius/react-user-media/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221820606,"owners_count":16886222,"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":[],"created_at":"2024-07-31T07:00:36.232Z","updated_at":"2024-10-28T11:15:25.046Z","avatar_url":"https://github.com/vardius.png","language":"TypeScript","funding_links":["https://github.com/sponsors/vardius"],"categories":["Packages","TypeScript"],"sub_categories":[],"readme":"React UserMedia\n================\n[![Build Status](https://travis-ci.org/vardius/react-user-media.svg?branch=master)](https://travis-ci.org/vardius/react-user-media)\n[![npm version](https://img.shields.io/npm/v/@vardius/react-user-media.svg)](https://www.npmjs.com/package/@vardius/react-user-media)\n[![npm downloads](https://img.shields.io/npm/dm/@vardius/react-user-media.svg)](https://www.npmjs.com/package/@vardius/react-user-media)\n[![license](https://img.shields.io/github/license/vardius/react-user-media.svg)](LICENSE)\n[![codecov](https://codecov.io/gh/vardius/react-user-media/branch/master/graph/badge.svg)](https://codecov.io/gh/vardius/react-user-media)\n\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Content\u003c/summary\u003e\n\n\u003c!-- toc --\u003e\n- [About](#about)\n- [How to use](#how-to-use)\n  - [Installation](#installation)\n  - [Examples](#examples)\n    - [Hook](#hook)\n    - [Context](#context)\n      - [Context Hook](#context-hook)\n      - [HOC](#hoc)\n- [License](#license)\n\u003c!-- tocstop --\u003e\n\n\u003c/details\u003e\n\nABOUT\n==================================================\nReact wrapper for getUserMedia.\n\nContributors:\n\n* [Rafał Lorenz](http://rafallorenz.com)\n\nWant to contribute ? Feel free to send pull requests!\n\nHave problems, bugs, feature ideas?\nWe are using the github [issue tracker](https://github.com/vardius/react-user-media/issues) to manage them.\n\n\u003c!-- ![Dashboard](../master/.github/kubernetes-dashboard-overview.png)\n![Dashboard](../master/.github/kubernetes-dashboard-pods.png) --\u003e\n\nHOW TO USE\n==================================================\n\n1. [Chat Example](https://github.com/vardius/react-webrtc-chat)\n\n## Getting started\n### Installation\n```bash\nnpm install @vardius/react-user-media\n```\n### Examples\nUse `useUserMedia` hook to request user media from navigator.\n#### Hook\n```javascript\nimport React from 'react';\nimport { UserMediaError, useUserMedia } from '@vardius/react-user-media';\n\nfunction App() {\n  const { stream, error } = useUserMedia({ audio: true, video: true });\n\n  if (error) {\n    return (\n      \u003cUserMediaError error={error} /\u003e\n    );\n  }\n\n  return (\n    \u003cvideo autoPlay ref={video =\u003e { video.srcObject = stream }} /\u003e\n  );\n}\n\nexport default App;\n```\n#### Context\nUse `UserMediaProvider` to request user media from navigator and pass it down with context.\n```javascript\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { UserMediaProvider } from '@vardius/react-user-media';\n\nimport App from './App';\n\nReactDOM.render(\n    \u003cUserMediaProvider constraints={{ audio: true, video: true }}\u003e\n        \u003cApp /\u003e\n    \u003c/UserMediaProvider\u003e,\n    document.getElementById(\"root\")\n);\n```\nyou can access context user media value in two ways:\n##### Context Hook\n```javascript\nimport React from 'react';\nimport { UserMediaError, useUserMediaFromContext } from '@vardius/react-user-media';\n\nfunction App() {\n  const { stream, error } = useUserMediaFromContext();\n\n  if (error) {\n    return (\n      \u003cUserMediaError error={error} /\u003e\n    );\n  }\n\n  return (\n    \u003cvideo autoPlay ref={video =\u003e { video.srcObject = stream }} /\u003e\n  );\n}\n\nexport default App;\n```\n##### HOC\n```javascript\nimport React from 'react';\nimport { UserMediaError, withUserMedia } from '@vardius/react-user-media';\n\nfunction App({ userMedia }) {\n  const { stream, error } = userMedia;\n\n  if (error) {\n    return (\n      \u003cUserMediaError error={error} /\u003e\n    );\n  }\n\n  return (\n    \u003cvideo autoPlay ref={video =\u003e { video.srcObject = stream }} /\u003e\n  );\n}\n\nexport default withUserMedia(App);\n```\n\nLicense\n-------\n\nThis package is released under the MIT license. See the complete license in the package:\n\n[LICENSE](LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Freact-user-media","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvardius%2Freact-user-media","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvardius%2Freact-user-media/lists"}