Listen to router changes globally

Hey,

we’re using Spring Boot with Vaadin and I’d like to listen to the BeforeEnterObserver event globally (not specific to a component). What’s the best way to achieve this?

You can register BeforeEnterListener on UI level

Sorry I’m relatively new to Vaadin. How to do this? Is it something for the VaadinServiceInitListener?

Correct in there you can call:

serviceInitEvent.getSource()
.addUIInitListener(uiInitEvent → uiInitEvent.getUI()
.addBeforeEnterListener(YOUR_Listener_Instance));