{"id":20678792,"url":"https://github.com/olistic/react-use-media","last_synced_at":"2025-10-17T05:51:29.138Z","repository":{"id":81392979,"uuid":"155858967","full_name":"olistic/react-use-media","owner":"olistic","description":"React hook for testing and monitoring media queries","archived":false,"fork":false,"pushed_at":"2018-12-28T17:31:52.000Z","size":96,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-10T19:32:10.338Z","etag":null,"topics":["hooks","react"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/olistic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-02T11:49:55.000Z","updated_at":"2018-12-28T17:31:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"39276b70-ad06-4117-b59b-06525ff0f84f","html_url":"https://github.com/olistic/react-use-media","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olistic/react-use-media","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olistic%2Freact-use-media","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olistic%2Freact-use-media/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olistic%2Freact-use-media/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olistic%2Freact-use-media/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olistic","download_url":"https://codeload.github.com/olistic/react-use-media/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olistic%2Freact-use-media/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262941543,"owners_count":23388148,"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"],"created_at":"2024-11-16T21:22:17.909Z","updated_at":"2025-10-17T05:51:29.053Z","avatar_url":"https://github.com/olistic.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-use-media\n\nReact hook for testing and monitoring media queries.\n\n[![Travis][build-badge]][build] [![Codecov][codecov-badge]][codecov]\n\n## Installation\n\n```sh\n$ npm install --save react-use-media\n```\n\nAdditionally, you'll need to install version `16.7.0-alpha.0` of `react` and\n`react-dom` since this package relies on\n[React Hooks](https://reactjs.org/hooks):\n\n```sh\n$ npm install --save react@16.7.0-alpha.0 react-dom@16.7.0-alpha.0\n```\n\n\u003e **DISCLAIMER:** React Hooks are an experimental proposal. The Hooks API, as\n\u003e well as this library's, are unstable and subject to change.\n\n## Usage\n\n```js\nimport React from 'react';\nimport useMedia from 'react-use-media';\n\nfunction MyComponent() {\n  const matches = useMedia('(max-width: 599px)');\n  return matches ? (\n    \u003cp\u003eThe document is less than 600px wide.\u003c/p\u003e\n  ) : (\n    \u003cp\u003eThe document is at least 600px wide.\u003c/p\u003e\n  );\n}\n```\n\n## API Reference\n\n### `useMedia`\n\n```js\nconst matches = useMedia(mediaQueryString, options);\n```\n\nAccepts a media query string as the first argument (`mediaQueryString`) and\nreturns whether it matches or not.\n\nOptionally, you can pass a second argument to `useMedia` that is an object with\nthe following properties:\n\n- `initialMatches` (_boolean_): The value of `matches` on first mount. Defaults\n  to `true`.\n\n[build-badge]: https://img.shields.io/travis/olistic/react-use-media/master.svg\n[build]: https://travis-ci.org/olistic/react-use-media\n[codecov-badge]:\n  https://img.shields.io/codecov/c/github/olistic/react-use-media/master.svg\n[codecov]: https://codecov.io/gh/olistic/react-use-media\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folistic%2Freact-use-media","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folistic%2Freact-use-media","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folistic%2Freact-use-media/lists"}