How can I hide a MenuItem in a MenuBar depending on the Route value ?

for example, i would to hide the “admin” MenuItem in my MenuBar if the Route is not …/admin !

The navigation lifecycle events are detected also in main layout (i.e. the one implementing RouterLayout). So for example if your user navigates to Route “admin” and you have added BeforeEnterObserver or AfterNavigationObserver to your mainlayout, the beforeEnter and afterNabigation methods are called in main layout too. So you can check there if the route is “admin” and do necessary things. I assume you have setup the menu in your main layout.

\u0000Hello Tatu and thank you for your answer.\nYou say : "[…]
So you can check there if the route is "admin" and do necessary things."
\nHow can I check if the route is admin ?\nAm trying to get and/or set this value but i can not find how to do \uD83E\uDD37\uD83C\uDFFC\u200D\u2642\uFE0F !

You can get the location and path via AfterNavigationEvent for example:

@Override
public void afterNavigation(AfterNavigationEvent event) {
	Location location = event.getLocation();
	String path = location.getPath();
}