How do I render the main navigation menu?
Here is how to get the render Array :

  $menuService = \Drupal::service('menu.link_tree');
  $parameters = $menuService-&gt;getCurrentRouteMenuTreeParameters('main');
  $mainMenutree = $menuService-&gt;load('main', $parameters);
  $renderArray = $menuService-&gt;build($mainMenutree);


If needed, here is how to generate the HTML

$html = \Drupal::service('renderer')-&gt;render($renderArray);


Note : replace 'main' by menu name for another one.