Drupal is a registered trademark of Dries Buytaert
cms 2.1.3 Update released for Drupal core (2.1.3)! drupal 10.5.11 Update released for Drupal core (10.5.11)! drupal 11.3.11 Update released for Drupal core (11.3.11)! drupal 11.2.13 Update released for Drupal core (11.2.13)! drupal 10.6.10 Update released for Drupal core (10.6.10)! cms 2.1.2 Update released for Drupal core (2.1.2)! drupal 11.1.10 Update released for Drupal core (11.1.10)! drupal 10.5.10 Update released for Drupal core (10.5.10)! drupal 10.4.10 Update released for Drupal core (10.4.10)! drupal 11.2.12 Update released for Drupal core (11.2.12)! drupal 11.3.10 Update released for Drupal core (11.3.10)! drupal 10.6.9 Update released for Drupal core (10.6.9)! drupal 10.6.8 Update released for Drupal core (10.6.8)! drupal 11.3.9 Update released for Drupal core (11.3.9)! drupal 11.3.8 Update released for Drupal core (11.3.8)! drupal 11.3.7 Update released for Drupal core (11.3.7)! drupal 11.2.11 Update released for Drupal core (11.2.11)! drupal 10.6.7 Update released for Drupal core (10.6.7)! drupal 10.5.9 Update released for Drupal core (10.5.9)! cms 2.1.1 Update released for Drupal core (2.1.1)!

mobile_detect

6,028 sites Security covered
View on drupal.org

This is a lightweight mobile detection module based on the Mobile_Detect.php library, which can be obtained from the GitHub repository.

This module is designed to assist developers using mobile-first and responsive design techniques who also need to apply slight variations for mobile and tablet users.

An example use case would be showing or hiding a block based on the type of device.

Installation

Use composer to install the module and its dependencies.
composer require 'drupal/mobile_detect:^4.0'

What does it do?

This module allows you to configure block visibility conditions based on device type or platform via the Drupal user interface.

The Mobile Detect Status block is included for testing purposes.

You can also use it programmatically in your PHP code or within Twig templates.

PHP

$md = \Drupal::service('mobile_detect');
$is_mobile = $md->isMobile();
$is_tablet = $md->isTablet();

Twig Extensions

{% if is_mobile() %}
{% if is_tablet() %}
{% if is_device('iPhone') %}
{% if is_ios() %}
{% if is_android_os() %}

There are not major upgrades so moving from 3.0.0 to 4.0.0 is safe.

Activity

Total releases
1
First release
May 2025
Latest release
1 year ago
Release cadence
Stability
100% stable

Releases

Version Type Release date
4.0.0 Stable May 18, 2025