Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Mobile Detect

5,744 sites Security covered Drupal 10–11
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.

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
1
Tracked since
May 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
4.0.0 Stable 10–11 May 18, 2025