{"id":16983503,"url":"https://github.com/dbish6/detect-if-mobile","last_synced_at":"2026-04-11T02:02:27.033Z","repository":{"id":224630075,"uuid":"755663058","full_name":"dBish6/detect-if-mobile","owner":"dBish6","description":"This is a dependency which is a small utility to check if a user is on a mobile device in a comprehensive way.","archived":false,"fork":false,"pushed_at":"2024-03-31T20:10:54.000Z","size":246,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T01:48:44.842Z","etag":null,"topics":["dependency","detect","detection","javascript","jest","npm","npm-package","typescript"],"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/dBish6.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","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}},"created_at":"2024-02-10T19:40:20.000Z","updated_at":"2024-03-31T20:10:19.000Z","dependencies_parsed_at":"2024-03-31T21:23:06.184Z","dependency_job_id":"ce2d62bb-d655-48e7-98fd-6fede6023008","html_url":"https://github.com/dBish6/detect-if-mobile","commit_stats":null,"previous_names":["dbish6/detect-if-mobile"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Fdetect-if-mobile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Fdetect-if-mobile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Fdetect-if-mobile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dBish6%2Fdetect-if-mobile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dBish6","download_url":"https://codeload.github.com/dBish6/detect-if-mobile/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244890120,"owners_count":20527030,"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":["dependency","detect","detection","javascript","jest","npm","npm-package","typescript"],"created_at":"2024-10-14T02:28:44.740Z","updated_at":"2026-04-11T02:02:22.009Z","avatar_url":"https://github.com/dBish6.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/dBish"],"categories":[],"sub_categories":[],"readme":"# detect-if-mobile\nA small utility to check if a user is on a mobile device in a comprehensive way.\n\n## Installation\nThis package works as long as you're running it in the browser. It seamlessly integrates with front-end environments and frameworks, including Vanilla, Vue, React, and more.\n\n```\n$ npm i detect-if-mobile\n```\n\n## Examples\nThese are a few common use cases. The package is flexible and not restricted to these examples. \u003cbr /\u003e\n**Returns a boolean:** *true for mobile, false not mobile*.\n\n### React\n```\nimport { useEffect } from \"react\";\nimport { isMobile } from \"detect-if-mobile\";\nimport { useGlobalContext } from \"@contexts/GlobalContext\";\n\nconst isMobileExample = () =\u003e {\n  const { isMobileRef } = useGlobalContext(); // You don't need to use a context, you can just store it in a variable, ref or state.\n  \n  useEffect(() =\u003e {\n    isMobileRef.current = isMobile(); // Now you can use this throughout your app!\n  }, [])\n}\n\nexport default isMobileExample;\n```\n### Vue\n```\nimport { ref, onMounted, onBeforeUnmount } from \"vue\";\nimport { isMobile } from \"detect-if-mobile\";\n\nexport default {\n  setup() {\n    const isMobileRef = ref(false);\n\n    const detectIfMobile = () =\u003e {\n      isMobileRef.value = isMobile();\n    };\n\n    onMounted(() =\u003e {\n      detectIfMobile();\n      window.addEventListener(\"resize\", detectIfMobile); // You can also use a resize listener, although it is not very necessary.\n    });\n\n    onBeforeUnmount(() =\u003e {\n      window.removeEventListener(\"resize\", detectIfMobile);\n    });\n\n    return {\n      isMobile: isMobileRef\n    };\n  }\n};\n```\n\n### Other\n```\nconst { isMobile } = require(\"detect-if-mobile\");\n\nif (isMobile()) {\n    console.log(\"This is a mobile device.\");\n} else {\n    console.log(\"This is not a mobile device.\");\n}\n```\n\n## Contributing\nContributions are welcome! Although I'd like to keep this package as small as possible since it is meant to be a small utility.\n\n### To Get Started\n- Fork this repository.\n- Create a new branch.\n- install the dependencies with `npm install`.\n- Do a `npm run test` to see if you're all set.\n- For the dev environment, `npm run dev` and there you go!\n\n```\n$ npm install\n$ npm run test\n$ npm run dev\n```\n\n## License\nThis project is licensed under the [MIT](https://github.com/dBish6/detect-if-mobile/blob/master/LICENSE) License.\n\n\n## Support Me\nIf you find this package helpful consider buying me a coffee, your support helps me stay motivated!\n\n\u003ca href=\"https://www.buymeacoffee.com/dBish\" target=\"_blank\"\u003e\u003cimg src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" style=\"height: 60px !important;width: 217px !important;\" \u003e\u003c/a\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbish6%2Fdetect-if-mobile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbish6%2Fdetect-if-mobile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbish6%2Fdetect-if-mobile/lists"}