How do I render an entity view mode like 'teaser' in a twig template? I have an entity reference field in one content referencing an other content.

What I'm trying to achieve is to display that reference in a teaser format programmatically.

I was hoping that I could do something like this :

{{ node.field_entity_ref.view('teaser') }}


But that doesn't work. Do I need to declare a preprocess anyway ? If so what's the best practice ?
The best practice would be to configure the reference field in UI as teaser and use it in the node template:

{{ content.field_entity_ref }}


If this is not an option for your case, you would probably need some code in preprocess.

But much easier is to use the module Twig Tweak, which can render nodes without preprocess:

{{ drupal_entity('node', node.field_entity_ref.0.target_id, 'teaser') }}