levithomason / canibrowse

Browser detection and check API
2 stars 0 forks source link

Can I Browse [CircleCI]() [David]()

Determine if your user's are using a supported browser.

Why?

Usage

Hit the API with the browsers you support as query params:

https://canibrowse.now.sh?chrome=60

Response in Chrome >= 60:

{
  canBrowse: true           // did the user agent meet the requirements?

  detected: {               // user agent detection results
    name: 'Chrome',
    chrome: true,
    version: '60.0',
    blink: true,
    mac: true,
    osversion: '10.12.5',
    a: true,
  },
}

Examples

πŸ’‘Detection is done with bowser. All of its browser flags are supported.

IE >= 9

By default, browsers you do not specify are considered supported.

https://canibrowse.now.sh?msie=9

Chrome Firefox IE8 IE9
βœ“ βœ“ βœ– βœ“

Only Chrome and Firefox

Use strict if you support only the specified browsers and no others.

https://canibrowse.now.sh?strict&chrome&firefox

Chrome Firefox IE Safari
βœ“ βœ“ βœ– βœ–

Blacklist specific browsers

Pass a browser as false to exclude all versions.

https://canibrowse.now.sh?msie=false

Chrome Firefox IE Safari
βœ“ βœ“ βœ– βœ“

Whitelist specific browsers

Pass a browser as true or without a value to include all versions.

https://canibrowse.now.sh?strict&chrome=true
https://canibrowse.now.sh?strict&chrome

Chrome 1 Chrome ∞ Other browsers
βœ“ βœ“ βœ–

Specify mobile or tablet

You can specify mobile or tablet.

https://canibrowse.now.sh?mobile=false&tablet=false

Mobile Tablet Desktop
βœ– βœ– βœ“

Debug what is going on

Pass debug to see more info on the detection and requirements.

https://canibrowse.now.sh?debug&chrome=60

{
  canBrowse: true           // did the user agent meet the requirements?

  detected: {               // user agent detection results
    name: 'Chrome',
    chrome: true,
    version: '60.0',
    blink: true,
    mac: true,
    osversion: '10.12.5',
    a: true,
  },

  strict: false,            // was strict enabled
  mobile: false,            // was mobile enabled
  tablet: false,            // was tablet enabled

  browsers: {               // browser requirements generated form the request
    chrome: {
      minVersions: ['60'],
      whitelisted: false,
      blacklisted: false,
    },
  },
}

Just get detection info

Only returns the user agent detection results, perhaps to do your own checks against.

https://canibrowse.now.sh/detect

{
  name: 'Chrome',
  chrome: true,
  version: '60.0',
  blink: true,
  mac: true,
  osversion: '10.12.5',
  a: true,
}

Send a custom user agent

You can pass a ua query param or override the User-Agent header.

Features I'd :heart: to see

These are possible with the current libraries we use, they just to be implemented. PRs welcome.

Query browser versions

Specify supported browsers by a Browserslist query like last 2 versions or > 5%.

https://canibrowse.now.sh?query=last 2 versions

Older 2 version old Current
βœ– βœ“ βœ“

Credits

Can I Browse is uses bowser for user agent parsing and compatibility checks and Browserslist for browser list queries.

Browser detection and browser list query issues should be opened on the main repos.