Learn Streamlit

Turn Python scripts into interactive data apps with no front-end code

16 lessons · 3 hours · 4 levels · covers Streamlit 1.66

Streamlit is an open-source Python framework for building interactive web apps for data, machine learning and internal tools. You write a plain script with calls like st.slider and st.dataframe; Streamlit reruns it on every interaction and renders the result in the browser, with caching, session state, multipage navigation and chat elements built in.

Before you start

Streamlit builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics5 lessons · 52 min in total
2. PracticalUse it productively at work, with the usual idioms10 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs13 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know16 lessons · 3 hours in total

The Streamlit tree

StreamlitScripts that rerun: the execution modelScripts that rerun: theexecution modelDisplaying text, data and metricsDisplaying text, dataand metricsInput widgetsInput widgetsCharts and mapsCharts and mapsLayout: sidebar, columns, tabs and containersLayout: sidebar,columns, tabs and…Caching with st.cache_data and st.cache_resourceCaching withst.cache_data and…Session state and callbacksSession state andcallbacksForms: batching inputForms: batchinginputMultipage apps with st.navigationMultipage apps withst.navigationSecrets and data connectionsSecrets and dataconnectionsRunning Python: REPL and scriptsRunning Python:REPL and scriptsDataFrameDataFrameDefining functionsDefining functionsIterators and generatorsIterators andgeneratorsTesting with pytest and unittestTesting with pytestand unittestThreads, processes and concurrent.futuresThreads, processesand concurrent.fut…
Essentials and Practical shown (10 of 16 lessons); the full list is below. Click a lesson to read it.

All 16 lessons, in order

The rerun model and basics

  1. Scripts that rerun: the execution model · Essentials · 10 min

    A Streamlit app is a Python script that reruns from top to bottom every time a user interacts with it.

  2. Displaying text, data and metrics · Essentials · 10 min

    Show text, Markdown, DataFrames, metrics, JSON and code with st.write and the dedicated display elements.

Widgets, charts and layout

  1. Input widgets · Essentials · 12 min

    Collect user input with buttons, sliders, text inputs, select boxes and file uploaders, and understand what each returns.

  2. Charts and maps · Essentials · 10 min

    Display charts with Streamlit's built-in chart elements or with Matplotlib, Plotly, Altair and other libraries.

  3. Layout: sidebar, columns, tabs and containers · Essentials · 10 min

    Arrange elements with the sidebar, columns, tabs, expanders, containers and placeholders, and configure the page.

State, caching and forms

  1. Caching with st.cache_data and st.cache_resource · Practical · 14 min

    Avoid repeating slow work on every rerun by caching data results and shared resources, with TTLs and invalidation.

  2. Session state and callbacks · Practical · 14 min

    Keep values across reruns with st.session_state, link it to widget keys, and react to changes with on_change and on_click callbacks.

  3. Forms: batching input · Practical · 10 min

    Group widgets in st.form so the app reruns only when the user submits, not on every change.

  4. Fragments, dialogs and controlling reruns · Advanced · 14 min

    Rerun only part of a page with st.fragment, refresh it on a timer, open modal dialogs, and trigger reruns with st.rerun.

Multipage and real apps

  1. Multipage apps with st.navigation · Practical · 12 min

    Split an app into pages with st.Page and st.navigation, group them in sections, and link or switch between pages.

  2. Secrets and data connections · Practical · 12 min

    Store credentials in secrets.toml, read them with st.secrets, and query databases and APIs with st.connection.

  3. Chat and LLM apps · Advanced · 12 min

    Build conversational interfaces with st.chat_message, st.chat_input and st.write_stream, keeping history in session state.

Testing and production

  1. Testing apps with AppTest · Advanced · 12 min

    Write fast, headless tests for Streamlit apps with streamlit.testing.v1.AppTest and pytest.

  2. Configuration, deployment and authentication · Expert · 15 min

    Configure apps with config.toml, deploy to Community Cloud or containers, add OIDC login with st.login, and plan for scaling.

Architecture and extending

  1. Architecture: sessions, threads and reruns · Expert · 16 min

    Understand how the Streamlit server, sessions, script threads, widget IDs and caches interact, to debug subtle bugs and design scalable apps.

  2. Custom components · Expert · 14 min

    Extend Streamlit with your own HTML, CSS and JavaScript using st.html and st.components.v2, exchanging data with Python.