Socket
Book a DemoInstallSign in
Socket

@digitalrelab/react-browser-support

Package Overview
Dependencies
Maintainers
6
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@digitalrelab/react-browser-support

A simple React hook to render contents based on browser support. TypeScript ready.

1.0.0
latest
npmnpm
Version published
Maintainers
6
Created
Source

React Browser Support

A simple React hook to render contents based on browser support. TypeScript ready.

https://img.shields.io/badge/typescript-v3.5.3-blue.svg semantic-release Commitizen friendly MIT

Requirements

  • React v16.8+

Install

yarn add @digitalrelab/react-browser-support

or

npm install @digitalrelab/react-browser-support

Quick start

import { useBrowserSupport } from "@digitalrelab/react-browser-support"

export const App: React.FC = () => {
  const isBrowserSupported = useBrowserSupport({ ie: false })

  // Will render for IE only.
  if (!isBrowserSupported) {
    return <div>Friends don't let friends use IE.</div>
  }

  return <div>Oh yeah, your browser is great!</div>
}

In depth

useBrowserSupport(browsersRules: TBrowsersRules): boolean

This method returns true when current browser is actually supported. false otherwise.

What are browsersRules?

The keys of browsersRules are equivalent to a browsers' names. Their values can be whether it's disabled or not (false or true), or the minimum version to run on that browser. i.e.

useBrowserSupport({ ie: false, chrome: 48 })

The above means that all IE versions are disabled, and Chrome requires version higher than 48.

Browsers available

  • chrome
  • ie
  • firefox
  • safari
  • opera
  • edge

License

Brought to you by DigitalReLab, LLC. MIT.

FAQs

Package last updated on 22 Jul 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.