If UI#getRouter() is deprecated, what should be use instead?

I noticed that UI#getRouter() is deprecated. The comments are as follows:

For internal use only. Will be removed in the future.

Is there an alternative approach that developers should use moving forward? Unless I am mistaken, there is only one Router per UI, so I do not understand why this is deprecated.



It’s impl delegates to getInternals().getRouter() and this is not deprecated.

Was it removed because of UI API cleanup (duplicated API to retrieve the router from the UI both via getRouter() and getInternals().getRouter()), or was there some other reason?

This is the only thing which I can find: https://github.com/vaadin/flow/commit/51d6bd997687bf092128ead03882fce85356b982

The reason is indeed that Router is a low level tool that exposes API that might have surprising effects if not used correctly. You should typically use high-level APIs such as one of the navigate methods in the UI class.

If there’s something in Router for which there isn’t a corresponding high-level API, then please describe the use case that you’re trying to achieve so that we can discuss how that should be supported.

I do not use it now, but see myself using Router#getRegistry() in the future.