Is there way to send a user to a web page programmatically without the user clicking anything?
My use case is that a user enters some data in a form and clicks a “Submit” button. The Streamlit application does some processing (e.g. creating the user record in a database, etc.) and redirects the user to another web page. The destination URL will be determined by the data entered into the form. Ideally, I could optionally open a new tab or browser window for the destination URL. The destination URL is not necessarily another Streamlit app.
While I could create a button or markdown link with a hyperlink (per some other articles) and have the user click, this is an extra step that I would like to avoid.
Seems like a common use case and I may be missing something obvious in the docs or a common workaround. Any help would be appreciated.
This does not work because there is a fundamental misunderstanding about how Streamlit works.
Streamlit consists of a frontend and backend part.
Any interaction with streamlit must be done via the browser or browser APIs.
Anything trying to bypass this, may work on your local computer, but will fail as soon as streamlit is hosted, i.e. streamlit no longer runs on the same computer as the browser.
What happens when webbrowser is used? A browser is started on the computer on which the python application is running. But there is no browser on streamlit cloud and even if there was, it would be the wrong computer.
It helps to remember all the quotes.
I hope this helps someone else! (edited - note that the above produces an error, but I found the issue - apparently it needs to return something; I’m returning the parent url below… but ignoring the return value.