Multipage apps: can the pages share data?


I would like to create a multipage app.
How can I share data between the different pages of such a multipage app?

My usage would be something like:

Page 1: define the data to be used
Page 2: display some statistics
Page 3: explore some data

I first use tabs for this purpose, but I don’t like the them form a UI point of view.
The UI would be nicer with a multipage app.
Especially for readability when there will be more than 10 pages (tabs).

Thanks for your suggestions


1 Like

Yes, you can use session state.


import streamlit as st
import pandas as pd

def app():
    st.title("DataFrame Creation")

    # Simple DataFrame creation for demo
    if 'df' not in st.session_state:
        st.session_state.df = pd.DataFrame({
            'A': range(1, 6),
            'B': range(10, 15)
        st.write("DataFrame created!")

    st.session_state.df = st.data_editor(st.session_state.df)

if __name__ == '__main__':


import streamlit as st

def app():
    st.title("DataFrame Statistics")

    if 'df' in st.session_state:
        st.write("Statistics of the DataFrame:")
        st.write("No DataFrame found. Please create it in the 'Create DataFrame' page.")

if __name__ == '__main__':

Sample output

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