Hello everyone ,
I have started a new project, stlite
( GitHub - whitphx/stlite: A port of Streamlit to Wasm, powered by Pyodide. ) which aims to make Streamlit completely run on browsers by using Wasm, with no servers.
Itās like JupyterLite for Jupyter, which inspired this project actually so much.
To try it out, I created a playground app with a code editor:
(~50MB will be downloaded including the Pyodide runtime and some Python packages)
Please visit the app and see Streamlit is running on the browser. I recommend to open the browser dev tools and watch the logs.
I also hosted a stlite package importable via <script />
tags that you can use on your web page like the following (Note that the URL can be changed in the future).
<script src="https://whitphx.github.io/stlite/lib/application/stlite.js" ></script>
<script>
stlite.mount({
mainScriptData: `
import streamlit as st
name = st.text_input("Name")
st.write("Hello, ", name or "world")
`
})
</script>
Please see the README for the details about it.
Playground app
The playground app is an SPA hosted on GitHub Pages. There is no server-side Python.
In addition, as itās also built as a PWA, it works in an offline environment after the first loading and caching, and it can be installed to your local environment as well. I think this is one major possibility of Streamlit on WASM - it works as a desktop/smartphone app (loading runtime is still slow though).
Project status
stlite is at the very beginning of its development, where only a subset of Streamlit functionality is working and there are many things to implement and improve.
For example, there are still not working components such as st.table
or st.line_chart
that make use of C-extensions such as PyArrow, PyDeck or PyZMQ (or maybe others)[1].
Custom components are also not supported.
There are many TODOs including below:
- Create a distributable package or other ways for the developers to use this library on their web pages (The
<script />
tag-based package is already being served).- NPM package
- Iframe embedding like Jupyter Lite: Jupyter Everywhere. Easily embed a console, a notebook, orā¦ | by Jeremy Tuloup | Jupyter Blog
- Support custom components
- Support file systems
- Currently only on-memory file system is supported, so the data evaporates on every reload.
- Dealing with the file system ā Version 0.20.0
- Support multi-file projects
- Currently only a single file can be input
- Support more components
- Components using C extensions
- Components using media resources like
<img>
tag.
Please also note that all the resources currently hosted such as the package file linked above above can be deleted or moved to elsewhere without any notice in the future, so do not use them in production for now.
The discussions before: Feature idea, Pyodide JupyterLite like Streamlit - #8 by whitphx
-
Technically, these libraries have native code e.g. C-extensions that have to be compiled with Emscripten for Pyodide runtime, which is kind of tough. Supporting these components is one major task. ā©ļø