How to get view mode of a node?
The view mode is in the vars:

function MYMODULE_preprocess_node(&amp;$vars) {
    $view_mode = $vars['view_mode'];
}


See template_preprocess_node() or node.html.twig for more info.