st.Page defines one page in a Streamlit multipage app. It connects a Python script with display metadata, including a navigation title and optional icon. section 8.4.1
Configure a page by supplying:
- A script path, such as "frontend/login.py", as the first argument. section 8.4.1
- A user-facing title, such as "Log in", for the navigation interface. section 8.4.1
- An icon string such as ":material/login:", using a Material Symbols icon name. section 8.4.1
Login and signup pages
pages = { "login": st.Page("frontend/login.py", title="Log in", icon=":material/login:"), "signup": st.Page("frontend/signup.py", title="Sign up", icon=":material/person_add:") } page = st.navigation([pages["login"], pages["signup"]]) page.run() The resulting app offers Log in and Sign up as selectable navigation pages. section 8.4.1
Listing 8.8 main.py, revised yet again
import streamlit as st
from backend.hub import Hub
pages = {
"login": st.Page("frontend/login.py", title="Log in",
icon=":material/login:"),
"signup": st.Page("frontend/signup.py", title="Sign up",
icon=":material/person_add:"),
}
if 'hub' not in st.session_state:
st.session_state.hub = Hub()
page = st.navigation([pages['login'], pages['signup']])
page.run()
Browse the complete revised main.py example, including page registration, session state, navigation, and page execution. section 8.4.1
