PHPackages                             superbig/craft3-mobiledetect - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. superbig/craft3-mobiledetect

ActiveCraft-plugin[Utility &amp; Helpers](/categories/utility)

superbig/craft3-mobiledetect
============================

Use Mobile\_Detect for detecting mobile devices (including tablets)

3.0.0(3mo ago)1953.3k↓50%2proprietaryPHPPHP ^8.2.0CI passing

Since Nov 5Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/sjelfull/craft3-mobiledetect)[ Packagist](https://packagist.org/packages/superbig/craft3-mobiledetect)[ RSS](/packages/superbig-craft3-mobiledetect/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (9)Used By (0)

MobileDetect plugin for Craft CMS 5
===================================

[](#mobiledetect-plugin-for-craft-cms-5)

Use Mobile\_Detect for detecting mobile devices (including tablets).

[![Screenshot](resources/img/icon.png)](resources/img/icon.png)

Requirements
------------

[](#requirements)

- Craft CMS 5.5.0 or later
- PHP 8.2 or later

Installation
------------

[](#installation)

1. Open your terminal and go to your Craft project:

    ```
     cd /path/to/project

    ```
2. Tell Composer to load the plugin:

    ```
     composer require superbig/craft3-mobiledetect

    ```
3. In the Control Panel, go to Settings → Plugins and click the "Install" button for MobileDetect.

Overview
--------

[](#overview)

A wrapper for the [Mobile\_Detect](https://github.com/serbanghita/Mobile-Detect) library (v4) by [@serbanghita](https://github.com/serbanghita).

Usage
-----

[](#usage)

### Twig

[](#twig)

```
{# Device detection #}
{{ craft.mobileDetect.isMobile ? 'I am mobile.' : 'I am not mobile.' }}
{{ craft.mobileDetect.isTablet ? 'Tablet' : 'Not a tablet' }}
{{ craft.mobileDetect.isPhone ? 'Phone' : 'Not a phone' }}

{# OS detection — magic methods #}
{% if craft.mobileDetect.isiOS %}
    Welcome, iOS user!
{% elseif craft.mobileDetect.isAndroidOS %}
    Welcome, Android user!
{% endif %}

{# Browser detection — magic methods #}
{% if craft.mobileDetect.isChrome %}
    You're using Chrome
{% elseif craft.mobileDetect.isSafari %}
    You're using Safari
{% endif %}

{# Generic rule matching #}
{{ craft.mobileDetect.is('iOS') }}
{{ craft.mobileDetect.is('WindowsPhoneOS') }}
{{ craft.mobileDetect.is('Firefox') }}
```

### PHP

[](#php)

```
$service = \superbig\mobiledetect\MobileDetect::getInstance()->mobileDetectService;
$isMobile = $service->isMobile();
$isIOS = $service->is('iOS');
```

Methods
-------

[](#methods)

### Device detection

[](#device-detection)

MethodDescription`isMobile`Returns `true` for any mobile device (including tablets)`isTablet`Returns `true` for tablets only`isPhone`Returns `true` for phones only (mobile but not tablet)### OS &amp; browser detection (magic methods)

[](#os--browser-detection-magic-methods)

Any `is*` call is forwarded to the library's rule matching. These work in both Twig and PHP:

MethodDescription`isiOS`iOS devices`isAndroidOS`Android devices`isBlackBerryOS`BlackBerry devices`isWindowsMobileOS`Windows Mobile devices`isWindowsPhoneOS`Windows Phone devices`isChrome`Chrome browser`isSafari`Safari browser`isFirefox`Firefox browser`is*`Any rule the library supports — see [Mobile\_Detect docs](https://github.com/serbanghita/Mobile-Detect)### Rule-based detection

[](#rule-based-detection)

MethodDescription`is(key)`Test any rule by name, e.g. `is('iOS')`, `is('AndroidOS')`, `is('Chrome')``match(pattern)`Test using a regular expression against the user agent`version(component)`Get the version of a component, e.g. `version('Android')`### Utility methods

[](#utility-methods)

MethodDescription`getVersion`Returns the Mobile\_Detect library version`getUserAgent`Get the current user agent stringUpgrading from v2 (Craft 4)
---------------------------

[](#upgrading-from-v2-craft-4)

### Breaking changes

[](#breaking-changes)

- **`mobileGrade`** — Removed (not available in Mobile\_Detect v4)
- **`getScriptVersion`** — Renamed to `getVersion`
- **`getCfHeaders` / `setCfHeaders`** — Replaced by `getCloudFrontHeaders` (service only)
- **`setUserAgent`** / **`setHttpHeaders`** — Available on the service only, not the Twig variable

### What still works

[](#what-still-works)

All `is*` magic methods (`isiOS`, `isAndroidOS`, `isChrome`, etc.) continue to work in Twig templates — no changes needed.

### PHP service access

[](#php-service-access)

The static `$plugin` property has been removed. Use `getInstance()`:

```
// Before (Craft 4)
MobileDetect::$plugin->mobileDetectService->isMobile();

// After (Craft 5)
MobileDetect::getInstance()->mobileDetectService->isMobile();
```

Brought to you by [Superbig](https://superbig.co)

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance82

Actively maintained with recent releases

Popularity36

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~604 days

Recently: every ~755 days

Total

6

Last Release

94d ago

Major Versions

1.0.2 → 2.0.02022-10-03

v2.x-dev → 3.0.02026-02-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/800b029eac606eb58930bcdf0d887e14aa63c31a203744c30befca8a58aa79b4?d=identicon)[superbig](/maintainers/superbig)

---

Top Contributors

[![sjelfull](https://avatars.githubusercontent.com/u/10508?v=4)](https://github.com/sjelfull "sjelfull (12 commits)")[![brandonkelly](https://avatars.githubusercontent.com/u/47792?v=4)](https://github.com/brandonkelly "brandonkelly (1 commits)")

---

Tags

craftcraft-plugincraft3craftcmscraftcms-plugincmsCraftcraftcmscraft-pluginmobiledetect

### Embed Badge

![Health badge](/badges/superbig-craft3-mobiledetect/health.svg)

```
[![Health](https://phpackages.com/badges/superbig-craft3-mobiledetect/health.svg)](https://phpackages.com/packages/superbig-craft3-mobiledetect)
```

###  Alternatives

[verbb/navigation

Create navigation menus for your site.

90683.7k17](/packages/verbb-navigation)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[verbb/comments

Add comments to your site.

13753.1k](/packages/verbb-comments)[verbb/tablemaker

Create customizable and user-defined table fields.

40168.8k1](/packages/verbb-tablemaker)[supercool/tablemaker

Create customizable and user-defined table fields.

40141.7k](/packages/supercool-tablemaker)[pennebaker/craft-architect

CraftCMS plugin to generate content models from JSON/YAML data.

72148.5k5](/packages/pennebaker-craft-architect)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
