Force Reload of Webpage

Is there a way of forcing the browser to refresh the page in streamlit? I’m not talking about st.experimental_rerun() which only reloads the script, but is there a way to force a page refresh (like hitting the refresh button on your browser) in streamlit?

I tried the following, but it doesn’t work on the newer versions of Streamlit.

import streamlit as st
from streamlit.server.server import Server

def refresh():
    Server.get_current()._reloader.reload()

if st.button('Refresh'):
    refresh()

Can anyone help? This seems like such a simple feature that is missing.

I guess you can use javascript.

1 Like

Here’s one way to do it with javascript, using the streamlit_js_eval library

import streamlit as st
from streamlit_js_eval import streamlit_js_eval

if st.button("Reload page"):
    streamlit_js_eval(js_expressions="parent.window.location.reload()")
6 Likes

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