Change URL without reload the page

Hello,
I want to change url without reload the page when ui initialize. I tried : Page.getCurrent().setUriFragment(url, true) But it does not work. Is there any way to change url without reload the page?

Tuğçe Avşar:
I want to change url without reload the page when ui initialize. I tried : Page.getCurrent().setUriFragment(url, true) But it does not work. Is there any way to change url without reload the page?

While there is no native Vaadin method to do it, it could be easily worked around with JavaScript:

getPage().getJavaScript().execute("history.pushState(history.state,'','" + newPath + '#' + newFragment + "');");

Further reading: [History API documentation]
(https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries)