Introducing multipage apps! 📄

I also found this problem and currently I’m using

<style>div[data-testid=stSidebarNav] {display: none !important;}</style>



Very interesting. This is an important feature.
But how to avoid that entered information on one page get lost when switching to another page?
Let’s say I have 2 pages: “settings” and “visualization”. In the first one I select all settings for plotting and in the second one I show the graph and do some animation.
Once I set everything in the first page and then move to the “visualization” page everything works but when I move back to the “settings” page (let’s say I want to update an entry) all the data that I previously entered are lost.

You can use session state to store variables from widgets across pages


Hey @hagsted,

Thank you for your comment! We think that those characters aren’t being recognized as emojis. IIRC we use a manual regex to detect emojis, but maybe we should just go for a library instead? Likely less buggy and more future-proof (as more emojis are added to the standard). TDLR: It’s likely a bug. Please file it. Thank you! :blush:

(Cc: @vdonato)

Hey @massimobrivio! Welcome to our forum! :smiley:

As @ac3 said, you can use Streamlit’s session state to store data across app reruns. Session state is also preserved when changing page! So here’s what you could do:

In 00_🛠️

import streamlit as st

colors = ["blue", "red"]
index = (
    if "settings" in st.session_state
    else 0
settings = st.selectbox(
    "What color for the visualization?", ["blue", "red"], index=index
st.session_state["settings"] = settings

In 01_🎨

import streamlit as st

if "settings" in st.session_state:
    st.write("Here are the settings you chose...", st.session_state.settings)
    st.write("No settings found. Head over to the settings page!")


CleanShot 2022-06-30 at 19.29.24

Let me know if that works. Hope it helps! More about st.session_state

1 Like

Very nice addition! Is there a way to share components, like a selectbox, across the different pages, in particular in the sidebar ? I managed to make it work by duplicating the code and keeping the choice in session_state but maybe there is a better way?

Hey @blz - welcome on board!

Unfortunately, I can’t think of a better way than what you described when it comes to sharing UI components across pages within the sidebar. Maybe simply put these into a function so at least you are not duplicating code?

Curious if you would envision a better way to achieve that?

Let me know how that goes :smiley:

1 Like

Hi @arnaud , thanks for the quick reply.

I couldn’t think of a better way and I am experiencing some limitations. I added a selectbox in the sidebar. In order to keep the selection across the pages I need to set a default index, the one corresponding to the last item selected.

The selection works fine the first time. From 2nd time I need to repeat it twice for it to work, it goes back to the previous item. Any idea what is happening?

Here is a minimal example, I hope it is clear: GitHub - blenzi/st_multipage_test: Test of multipage app with streamlit and selectbox in sidebar

Hi @blz,

I have tried running your app and I don’t see where the issue is: whenever I choose a selection, it is successfully stored while switching pages (even more than once). See below:

CleanShot 2022-07-05 at 11.28.34

If the issue persists, my suggestion is that you open a thread in the dedicated section “Using Streamlit” here to get more help :smiling_face:

Thanks @arnaud . The issue happens when you do a selection more than once in the same page. For example if you stay in “hello” and select B, then A again, it will go back to B.

Has anyone seen code or been able to reduce the whitespace above the individual pages in the sidebar? Alternatively, been able to expand the >>down arrow<< button by default.

I have 5 pages and have been attempting to list them all on the sidebar without clicking anything extra.

I absolutely LOVE this. My question is though are emojis the only thing I can put in the navigation buttons or can I use something a little more profesional looking like Bootstrap icons?

1 Like

I guess this has been noted already (I haven’t read every comment on this thread), but there is sometimes an annoying issue when using session state with multipage apps.

I have a home page ( and one page in my “pages” folder (

  1. I initialize some session state objects in
  2. I navigate to page1. The session state objects persist :–)
  3. I press refresh while I am on page1.
  4. My app crashes because my session state objects from no longer exist:
    'st.session_state has no key “now”. Did you forget to initialize it?

I guess this is expected, but does anyone have a nice solution to overcome his?


@LukeF Would the following check in pages/ work:

# pages/
import streamlit as st

if "now" not in st.session_state:
    st.session_state["now"] = ""

Thanks @snehankekre
Yes, I ended up doing a similar thing, except I need the variable in session state for the function on the page.
So I did as you suggested but also printed a message to “click the home page first”.


Definitely need something simple like st.sidebar.hide/ As Tony says, lots of us have a login page where we hide the sidebar. And then when you get back into the app, you have to show it again manually. This should be able to be done programaticaly

1 Like

Hi! This “multipage apps” layout works great. I would really appreciate if someone could help me with the following issue.

My current directory layout is like the following :-

├── pages
│ ├──
│ ├──

Here, If i try to import a function from in, say:-
“from import graphData”

I get a “ModuleNotFoundError: No module named ‘arbitraryFunction’” error.

Please help me with either the correct way or a work-around for the same.


Hi @nishantseth, welcome to the community.

Can you try using the following in your file:
from app import graphData

where app is

Hope this helps.

@dataprofessor Perfect! My IDE gives an error for this saying that the module does not exist, however it works in the Streamlit app. Does the work! Thank you!


Any update on the editable dataframe?