Default route in Vaadin Flow

I would like to have an explicit non-empty name for every view.
On top of that I want to let users use the default route (http://mylocationhttp://mylocation/mainView).
I tried using an alias on the relevant view, and I also tried, in addition to that, implementing BeforeEnterObserver and calling event.rerouteTo(“mainView”).
That works as expected but the URL still shows the empty route, while I’d like it to show ‘mainView’.

Can someone advice?

Thanks

Hi.

To update the URL you could do a event.getUI().getPage().getHistory().replaceState(null, "mainView"); in the event handler that does the rerouteTo or have it just for the mainView init that it pushes the replaceState.

The updating of the URL for a reroute was removed at early alpha (probably due to history handling, should it add or replace and how messy the back functionality then becomes).
To follow this theres the issue [BeforeEnterEvent’s rerouteTo doesn’t update the URL]
(https://github.com/vaadin/flow/issues/4189)

  • Mikael