Streamlit: new releases, stlite and Streamlit books
There have been two releases recently, 1.30.0 and 1.31.0, I look at these and other new features as well as Stlite, a serverless version of Streamlit
Streamlit version 1.30.0
Multi-page app navigation
The new version was released on January 11, 2024 and contains a few new features among which is st.switch_page
which allows you to programmatically switch pages in a multipage app. I have tried this out and it seems like a great improvement as you no longer have to rely on the sidebar to navigate between pages. You could go to a new page by pressing a button, but I have found that a pleasing method is to use the streamlit-option-menu
component.
I’ve published a tutorial on this, here on Substack:
Streamlit: Navigating Multi-page Apps with v1.30.0.
st.query_params()
This is a refinement of a previously experimental feature and allows you to retrieve URL parameters as a Python dict
.
For example, if your app is invoked with the following parameters:
https://your_app.streamlit.app/?key1=1&key2=two&key3=true
Using st.query_params() will return a dict
like this:
{ "key1" : "1", "key2" : "two", "key3" : "true" }
There are a few other enhancements, too: click on the heading for the v1.30.0 announcement.
Streamlit Version 1.31.0
And hard on the heels of 1.30.0 is version 1.32.0! Which, I have to admit I haven’t looked at in any detail yet. But it does include st.page_link
, which seems to be a nice way of linking to different pages in an app. Does this make my tutorial above redundant? I don’t think so, but may be it gives us an additional option for navigation design.
stlite: Serverless Streamlit
This is something that I’ve been meaning to look at and certainly will in the not-too-distant future. stlite
is a port of Streamlit to WASM that is powered by Pyodide. Which translated, means that you can run a Streamlit app in the browser with no need for a server.
If you are happy creating websites in HTML (and know Streamlit, of course) then this is a novel way of deploying a Streamlit app as a standalone web page without the need of pushing it to a server such as Streamlit Cloud.
You can see sample apps in the stlite
GitHub repo (click on the header, above).
Streamlit for Data Science: Create interactive data apps in Python 2nd ed. Edition
(affiliate link)
This book is, as the author says, “… for data scientists and ML enthusiasts, especially those who are new to Streamlit or data science in general”. It’s now in a second edition because Streamlit keeps releasing new versions!
The announcement in the Streamlit blog tells us that the book is in three sections:
The first section gives an introduction to building basic Streamlit apps. It covers visualizations, understanding the execution model, and introduces popular libraries. By the end of this section, you’ll have a working app and an ML model that you can share with anyone!
The second section focuses on beauty and complex use cases. It covers Streamlit components, databases, animations, and generative AI. By the end of this section, you’ll have enough knowledge to create production-level Streamlit apps for work or for a large audience.
The final section is project-based and explores the use of Streamlit in a working environment. It includes interviews with power users, discusses using Streamlit for job applications, and gives you a better understanding of Streamlit’s long-term direction.
It’s not a cheap book but it seems to cover a lot of ground. I read the first edition, which was useful, and this one must surely be more up-to-date in terms of both Streamlit features and its use in Data Science and Machine Learning.
Streamlit from Scratch
If you are looking for something (much) cheaper and more basic, might I recommend my own effort (see the link above). It introduces Streamlit from the ground up and covers all of the basic features including embedding media and creating charts in Plotly and the other supported charting libraries. By the end, you will have created a fully working dashboard-like application.