Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-mobile

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-mobile

Check if mobile browser.

  • 5.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
367K
decreased by-14.82%
Maintainers
1
Weekly downloads
 
Created

What is is-mobile?

The is-mobile npm package is a lightweight utility that helps in detecting if a user is accessing a website from a mobile device. It can be used to tailor user experiences based on the type of device being used.

What are is-mobile's main functionalities?

Basic Mobile Detection

This feature allows you to detect if the user is accessing the website from a mobile device. The function returns a boolean value.

const isMobile = require('is-mobile');

if (isMobile()) {
  console.log('User is on a mobile device');
} else {
  console.log('User is not on a mobile device');
}

Custom User-Agent String

This feature allows you to pass a custom User-Agent string to the isMobile function to determine if it corresponds to a mobile device.

const isMobile = require('is-mobile');

const userAgent = 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602.1';

if (isMobile({ ua: userAgent })) {
  console.log('User-Agent indicates a mobile device');
} else {
  console.log('User-Agent does not indicate a mobile device');
}

Custom HTTP Headers

This feature allows you to pass custom HTTP headers to the isMobile function to determine if they indicate a mobile device.

const isMobile = require('is-mobile');

const headers = { 'user-agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) Version/10.0 Mobile/14E5239e Safari/602.1' };

if (isMobile({ headers })) {
  console.log('HTTP headers indicate a mobile device');
} else {
  console.log('HTTP headers do not indicate a mobile device');
}

Other packages similar to is-mobile

Keywords

FAQs

Package last updated on 16 Oct 2024

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc