# ui.navigate | NiceGUI

[Button: icon:menu]

[](/)

[Installation](/#installation)

[Features](/#features)

[Demos](/#demos)

[Documentation](/documentation)

[Examples](/examples)

[Why?](/#why)

[Button]

[Button]

[](https://github.com/zauberzeug/nicegui/)

[Button: icon:more_vert]

# ui.*navigate*

## Navigation functions

These functions allow you to navigate within the browser history and to external URLs.

*Added in version 2.0.0*

main.py

[Button]

````python
from nicegui import ui

with ui.row():
    ui.button('Back', on_click=ui.navigate.back)
    ui.button('Forward', on_click=ui.navigate.forward)
    ui.button('Reload', on_click=ui.navigate.reload)
    ui.button(icon='savings',
              on_click=lambda: ui.navigate.to('https://github.com/sponsors/zauberzeug'))

ui.run()
````

## ui.navigate.to (formerly ui.open)

Can be used to programmatically open a different page or URL.

When using the `new_tab` parameter, the browser might block the new tab.
This is a browser setting and cannot be changed by the application.
You might want to use `ui.link` and its `new_tab` parameter instead.

:target: page function, NiceGUI element on the same page or string that is a an absolute URL or relative path from base URL
:new_tab: whether to open the target in a new tab (might be blocked by the browser)

main.py

[Button]

````python
from nicegui import ui

url = 'https://github.com/zauberzeug/nicegui/'
ui.button('Open GitHub', on_click=lambda: ui.navigate.to(url, new_tab=True))

ui.run()
````

## Push and replace URLs

The `history` API allows you to push and replace URLs to the browser history.

While the `history.push` method pushes a new URL to the history,
the `history.replace` method replaces the current URL.

See [JavaScript's History API](https://developer.mozilla.org/en-US/docs/Web/API/History) for more information.

*Added in version 2.13.0*

main.py

[Button]

````python
from nicegui import ui

ui.button('Push URL', on_click=lambda: ui.navigate.history.push('/a'))
ui.button('Replace URL', on_click=lambda: ui.navigate.history.replace('/b'))

ui.run()
````

**Nice**GUI

The Python UI framework that shows up in your browser.

[](https://github.com/zauberzeug/nicegui/)

[](https://discord.gg/TEpFeAaF4f)

[](https://www.reddit.com/r/nicegui/)

Resources

[Documentation](/documentation)

[Examples](/examples)

[LLM reference](/llms.txt)

[GitHub](https://github.com/zauberzeug/nicegui/)

[PyPI](https://pypi.org/project/nicegui/)

Community

[Discussions](https://github.com/zauberzeug/nicegui/discussions)

[Discord](https://discord.gg/TEpFeAaF4f)

[Reddit](https://www.reddit.com/r/nicegui/)

[Contributing](https://github.com/zauberzeug/nicegui/blob/main/CONTRIBUTING.md)

[Sponsors](https://github.com/sponsors/zauberzeug)

Legal

[Imprint](/imprint_privacy#imprint)

[Privacy](/imprint_privacy#privacy)

Made with NiceGUI by [Zauberzeug](https://zauberzeug.com)

© 2026 [Zauberzeug GmbH](https://zauberzeug.com)