What is the current page in use? Multipage App

Hi All,

I have a multipage app with a structure like:

Home.py
pages/1_๐Ÿ“ˆ_Plotting_Demo.py
pages/2_๐Ÿ“ˆ_Another_Demo.py

On each page I am setting the page config as follows:

st.set_page_config(page_title=โ€œPlotting Demoโ€, page_icon=โ€œ:chart_with_upwards_trend:โ€, layout=โ€˜wideโ€™)

Is it possible to access the name / title of the page? (which is currently being displayed / visited)

Best,
Mikkel

1 Like

Hey @Mikkel_Vestergaard,

There isnโ€™t a built-in way to do this, but you can grab the page title via the following:

from streamlit_javascript import st_javascript
import streamlit as st

url = st_javascript("await fetch('').then(r => window.parent.location.href)")
st.write(url.rsplit('/',1)[1])

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.