liveBook · Manning

St.Page

As explained in Build Python Web Apps with Streamlit

st.Page is a Streamlit API object that defines a page script together with metadata such as its title and icon for multipage navigation.

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

How Build Python Web Apps with Streamlit covers it

How deep it goes
Explains the script path, title, icon, and relationship to st.navigation, without descending into widget implementation.
Examples
Uses login.py and signup.py scripts with Log in, Sign up, and Material Symbols icons.
What it assumes
Assumes separate Python scripts represent the pages and introduces how to connect those scripts to navigation.
What you can do after
Operate/configure: register Python page scripts and expose them through a selectable Streamlit navigation bar.
How it connects
Connects st.Page with multipage apps, st.navigation, page links, and Material Symbols icons.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build Python Web Apps with Streamlit. The section links point to the parts of the book it draws on.