Last updated 17 July 2016. Created on 10 September 2014.
Edited by dkre, marwensf. Log in to edit this page.

drupal 8 module for detect mobile devices.

This is a lightweight mobile detection based on the Mobile_Detect.php library.
github link: mobile_detect

PHP examples

Check type device

$mobileDetector = \Drupal::service('krs.mobile_detect');

Check phone



Check tablet

is[BlackBerryTablet|iPad|Kindle|SamsungTablet|HTCtablet|MotorolaTablet|AsusTablet|NookTablet|AcerTablet| YarvikTablet|GenericTablet]


Check mobile OS



Twig Helper

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

Looking for support? Visit the forums, or join #drupal-support in IRC.