Opening the 2nd page from multipage app in a new tab


I have a multipage app with 2 pages when the user interacts to open the second page i want it to open in another tab rather than in the same tab, how can we do that

Debug info

  • Streamlit version: 1.25.1
  • Python version: 3.8
  • Using PipEnv
  • OS version: linux

This is possible, but the user will have two different sessions: any information they enter in the first tab will have no bearing on the second, and vice versa.

You can forcibly navigate to a page in your app by including the page in the URL with an HTML link set to open in a new tab:

st.markdown('<a href="/page_name" target="_blank">Go to page</a>', unsafe_allow_html=True)

If you had a page pages/ in your repository, this would look like:

st.markdown('<a href="/my_page" target="_blank">Go to page</a>', unsafe_allow_html=True)

(The next version of Streamlit will have a link button element so you won’t have to manually enter the HTML. Check out the roadmap. :balloon:)

1 Like

st.link_button was released with Streamlit 1.27.0! :confetti_ball:

1 Like