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])

3 Likes

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