This guide walks you through embedding a Streamlit app inside a brand-new Vite React project. By the end you will have a running browser-only Streamlit app rendered as a React component, with no Python server required.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/whitphx/stlite/llms.txt
Use this file to discover all available pages before exploring further.
Create a Vite React project
Scaffold a new project using the official Vite React TypeScript template:Any Vite React project works — the template is just a convenient starting point.
Install @stlite/react
Add
@stlite/react to the project. react and react-dom are peer dependencies; the Vite template already includes them.Configure vite.config.ts
Open
vite.config.ts and add the stliteReactPlugin. This plugin ensures the bundled Streamlit wheel files and Pyodide assets are emitted and addressable at runtime.Create the app
Replace the contents of
src/main.tsx with the following. This creates a kernel, defines an inline Streamlit script, and renders it using StliteAppWithToast.createKernel is called outside the component tree so the kernel is created only once — not re-created on every render. Alternatively, use the useKernel hook inside a component to tie the kernel’s lifetime to the component’s mount/unmount cycle.StliteApp vs StliteAppWithToast
StliteAppWithToast wraps StliteApp and adds a react-toastify overlay that displays:
- Load progress — shows messages while Pyodide and Streamlit are being initialised.
- Load errors — displays a toast when the kernel fails to start.
- Module auto-load — notifies when Streamlit’s module auto-loading feature installs new packages.
StliteApp directly:
StliteAppWithToast’s disableProgressToasts, disableErrorToasts, and disableModuleAutoLoadToasts props. See the API Reference for details.
About wheelUrls from @stlite/react/vite-utils
ThewheelUrls object imported from @stlite/react/vite-utils contains the resolved, hashed URLs of the bundled stlite-lib and streamlit Python wheel files that stliteReactPlugin emits during the build. Pyodide uses these URLs to install Streamlit in the in-browser Python environment.
stliteReactPlugin resolves these at build time. You should always pass this value to createKernel as wheelUrls rather than hard-coding paths manually.