react-device-detect

Detect device, browser, and OS type in React and conditionally render views accordingly

Library
npm
v2.2.3
2,919 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
44 /100 Fair
Development Activity 0
Maintenance 20
Community 56
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
64 /100 Good
Architecture 62
Code Quality 65
Innovation 45
Learning Curve 85

react-device-detect is a user-agent-sniffing library for React applications that identifies the current device type, browser, and operating system, then exposes both boolean selectors (isMobile, isBrowser, isIE) and dedicated view components (<BrowserView>, <MobileView>, <CustomView>) for conditionally rendering UI based on the detection result.

It’s explicitly scoped to scenarios where you need to know something specific about the device or browser itself — targeting a particular browser (Chrome, Safari, IE) or device category (all iPods, smart TVs, consoles) — as opposed to responsive layout concerns, which the README steers developers toward CSS media queries or matchMedia-based libraries instead. The library also exposes a testing escape hatch, letting tests override isMobile and similar flags directly.

What You Get

  • Boolean selectors like isMobile, isBrowser, isTablet, isIE, isChrome, and dozens more device/browser checks
  • Dedicated view components (BrowserView, MobileView, TabletView, CustomView) for conditional rendering by device type
  • String metadata such as browserName, osName, deviceType, and mobileModel for more granular logic
  • A withOrientationChange HOC for reacting to device orientation changes
  • A testing escape hatch that lets test suites directly override isMobile and other flags

Common Use Cases

  • Showing a “download our app” banner only to mobile visitors on a marketing site
  • Rendering a simplified UI variant specifically for smart TVs or game consoles browsing a web app
  • Displaying an unsupported-browser warning targeted at Internet Explorer users
  • Adjusting analytics or feature flags based on detected device/browser combination rather than screen size alone

Under The Hood

Architecture - The library is small and layered: src/lib/parse.js runs user-agent parsing (built on the ua-parser-js-style detection approach), src/lib/detect.js derives boolean device/browser flags from the parsed data, src/lib/buildSelectors.js and src/lib/selectors.js assemble the exported selector object, and src/components/views.js wraps those selectors into conditionally-rendering React components. src/components/hooks/ provides hook-based equivalents for consumers who prefer hooks over the view-component pattern.

Tech Stack - Plain JavaScript (no TypeScript source, though index.d.ts ships hand-written type declarations), built with Rollup per rollup.config.js, with React declared as a peer dependency so it doesn’t bundle its own copy.

Code Quality - Tests live in specs/ (get-ua-data.spec.js, types.spec.js, views.spec.js), covering both the raw detection logic and the exported view components. The library is compact (~250 lines across src/lib/), which keeps it easy to audit, though it has seen no recent commits, consistent with the README’s own framing that the library is intentionally narrow in scope and largely feature-complete for its purpose.

API Design - The dual API surface — plain booleans for quick conditionals (if (isMobile) ...) and JSX view components for declarative rendering (<MobileView>...</MobileView>) — covers both common consumption styles with no extra ceremony, and the README is explicit about when not to reach for this library (pointing to CSS media queries for pure responsive layout), which is a rare and useful bit of restraint in a library’s own documentation.

Used by 13 apps in this directory

TypeScript
72%
AGPL 3.0

APITable

Databases · Low Code Platforms

15,623

API-first collaborative spreadsheet-database platform that auto-generates REST APIs and lets teams build internal tools, CRMs, and dashboards without code.

View details
71
Repo Health
77
Technical
60
Dependency
Built with
TypeScript 72%
Java 22%
Updated 1 months ago
TypeScript
96%
Other

Amplication

AI Code Assistants · Automation · Developer Tools

16,015

Create production-ready backend services with your organization's standards baked in — generating NestJS, Prisma, and GraphQL code that you own and control.

View details
58
Repo Health
84
Technical
60
Dependency
Built with
TypeScript 96%
Updated 3 months ago
JavaScript
95%
MIT

AnythingLLM

AI Assistants · Automation · Developer Tools

66,533

The all-in-one AI platform for private document chat, no-code agents, and local LLMs with zero setup friction.

View details
90
Repo Health
78
Technical
64
Dependency
Built with
JavaScript 95%
Updated 1 weeks ago
TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 1 weeks ago
Go
49%
Other

Cosmos-Server

Authentication · Security

6,167

All-in-one self-hosted home server with SmartShield anti-DDoS, Nebula mesh VPN, automatic HTTPS, and a 250-app marketplace — all secured behind a unified auth layer.

View details
83
Repo Health
59
Technical
64
Dependency
Built with
Go 49%
JavaScript 48%
Updated 2 weeks ago
TypeScript
92%
MIT

Dittofeed

Automation · Marketing

2,968

Open-source omni-channel customer engagement platform for automating transactional and marketing messages via email, SMS, WhatsApp, Slack, and mobile push.

View details
54
Repo Health
75
Technical
62
Dependency
Built with
TypeScript 92%
Updated 6 months ago
Python
63%
BSD 3

Flagsmith

Ab Testing Experimentation · Developer Tools · Devops

6,577

Open-source feature flagging, remote config, and A/B/multivariate testing platform for web, mobile, and server-side apps — self-host or use the hosted SaaS.

View details
90
Repo Health
82
Technical
63
Dependency
Built with
Python 63%
TypeScript 31%
Updated 1 weeks ago
TypeScript
62%
Other

Flowise

AI Development · Automation · Developer Tools

55,490

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
82
Repo Health
77
Technical
63
Dependency
Built with
TypeScript 62%
JavaScript 27%
Updated 1 months ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,378

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
67
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers