Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Mobile Detect

Security covered Under active development 5,964 sites

This module helps you detect if a visitor is using a mobile device, tablet, or specific operating system. You can then use this information to show or hide content, like blocks, based on the device being used, either through the Drupal administration interface or in your code.

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.

Drupal 10–11

Ask your assistant about Mobile Detect

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

1 tracked project depends on this one

Activity

Tracked releases
4
Tracked since
Dec 2023
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Slowing

Release Timeline

Releases

Version Type Core PHP Release date
4.0.0 Stable 10–11 May 18, 2025
4.0.x-dev Dev 10–11 Dec 14, 2023
3.0.6 Stable 8–10 Dec 14, 2023
3.0.5 Stable 8–10 Dec 14, 2023