How to link to a page with new Page & Navigation setup

Hi all,

I have restructured my app using the new st.Page & st.Navigation set-up in 1.36.0 and want to know what is the best approach/practice to accomplish the following:

Currently I have 2 pages in my navigation “View documents” (view_documents.py) and “Upload documents” (upload_input_documents.py).

I want to hide “Upload documents” from the navigation and integrate it into “View documents” by adding a button that redirects to “Upload documents” that passes along a GET parameter.

Hope you can share your thoughts and ideas.

For me it look like you don’t need a page.
I will just make a function inside this page and hide the text to simulate te page switch.

import streamlit as st


def view_documents():
    st.title("View Documents")

    if st.session_state.get('page', '') != 'upload_documents':
        with st.container():
            st.title('view docs')
            st.text('NICE DOCS/PDF/XLSX\n'*20)
    else:
        upload_documents()

    if st.button("Upload Documents"):
        st.session_state.page = "upload_documents"
        st.rerun()


def upload_documents():
    st.header("Let's upload documents")

    # Your upload logic here
    if st.button("Back to View Documents"):
        st.session_state.page = "view_documents"
        st.rerun()

ViewDocumentsBrave2024-07-2116-33-35-ezgif.com-video-to-gif-converter

Thanks Faltawer for your proposed solution. That will definitely work but to keep things more logical and structured I would ideally have it in separate files.

I found with st-pages modules there is a concept of “hidden” pages that could work but ideally I stick with the new native st.Page & st.Navigation way. Is there a way to define a new page without making it a part of the navigation structure?

If not I’m going for your proposed solution.