Drupal is a registered trademark of Dries Buytaert
Protected Pages 3.0.0 Major update available for module protected_pages (3.0.0). Commerce Core 3.3.8 Minor update available for module commerce (3.3.8). Search API HTML Element Filter 1.0.7 Minor update available for module search_api_html_element_filter (1.0.7). Layout Builder Reorder 2.0.1 Minor update available for module layout_builder_reorder (2.0.1). Ban 1.1.0 Minor update available for module ban (1.1.0). Field Formatter Range 2.0.0 Major update available for module field_formatter_range (2.0.0). Field Formatter Range 8.x-1.8 Minor update available for module field_formatter_range (8.x-1.8). UI Patterns (SDC in Drupal UI) 2.0.18 Minor update available for module ui_patterns (2.0.18). Search API Solr 4.3.11 Module search_api_solr updated after 14 months of inactivity (4.3.11). Provus Mega Menu Module provus_mega_menu crossed 1,000 active installs.

Mobile Detect

5,979 sites Security covered
View on drupal.org

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.

Activity

Total releases
1
First release
May 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Release date
4.0.0 Stable May 18, 2025