How do I use a display mode for anonymous users, and another one for logged-in users?
This is similar to How do I change the node view mode before rendering?, only that you want to add conditions for the route name and the current user:

/**
 * Implements hook_entity_view_mode_alter().
 */
function mymodule_entity_view_mode_alter(&amp;$view_mode, $entity, $context) {
  if ($entity-&gt;getEntityTypeId() == 'node' &amp;&amp; $entity-&gt;bundle() == 'article') {
    if (\Drupal::routeMatch()-&gt;getRouteName() == 'entity.node.canonical') {
      if (\Drupal::currentUser()-&gt;isAnonymous()) {
        $view_mode = 'teaser';
      }
    }
  }
}