Hook for a new `UI` starting

The [Navigation Lifecycle]
(https://vaadin.com/docs/v14/flow/routing/tutorial-routing-lifecycle.html) in the Vaadin 14 manual says:

It is also possible to register a standalone listener for this event using the addBeforeEnterListener(BeforeEnterListener) method in UI.

But in modern Vaadin with the routing feature, we are no longer supposed to be writing a UI subsclass. My rough understanding is that there is indeed a UI object automatically instantiated for us, and then routing automatically replaces the content within that UI object. So the existence of a UI object is supposed to be transparent to us programmers using Vaadin Flow.

➥ So what is the lifecycle hook on a new UI instance so I can write a user-authentication check as a BeforeEnterListener to work globally across all my @Route views?

Calling [UI.getCurrent]
(https://vaadin.com/api/platform/14.0.0/com/vaadin/flow/component/UI.html#getCurrent--) will not do, as I would need to call that from somewhere in my layouts, but I am trying to register a listener before my layouts exist.

Resolved by [this post]
(https://stackoverflow.com/a/57551261/642706) on Stack Overflow using UIInitListener and VaadinServiceInitListener .

thanks :wink: