@stlite/desktop
@stlite/desktop allows you to convert your Streamlit application into a desktop app with Stlite runtime, a Pyodide-based Wasm-port of Streamlit.
Quick Start
Section titled “Quick Start”1. Initialize Project
Section titled “1. Initialize Project”Create a package.json file for your new project:
{ "name": "my-app", "version": "0.1.0", "main": "./build/electron/main.js", "scripts": { "dump": "dump-stlite-desktop-artifacts", "serve": "cross-env NODE_ENV=production electron .", "app:dir": "electron-builder --dir", "app:dist": "electron-builder", "postinstall": "electron-builder install-app-deps" }, "build": { "files": [ "build/**/*" ], "directories": { "buildResources": "assets" } }, "devDependencies": { "@stlite/desktop": "^0.91.1", "cross-env": "^7.0.3", "electron": "34.3.0", "electron-builder": "^25.1.8" }, "stlite": { "desktop": { "files": [ "app.py" ], "entrypoint": "app.py" } }}Run installation:
npm install# oryarn install2. Create Application
Section titled “2. Create Application”Create app.py:
import streamlit as st
st.write("Hello from Stlite Desktop!")3. Build & Run
Section titled “3. Build & Run”Dump artifacts (prepare build):
npm run dumpPreview:
npm run serveDistribute:
npm run app:distThis generates the application files (.app, .exe, etc.) in the dist directory.
Configuration
Section titled “Configuration”Configure your app via the stlite.desktop section in package.json.
Files and Dependencies
Section titled “Files and Dependencies”"stlite": { "desktop": { "files": ["app.py", "pages/*.py", "assets"], "entrypoint": "app.py", "dependencies": ["numpy", "pandas"], "requirementsTxtFiles": ["requirements.txt"] }}- files: Files and directories to include.
- entrypoint: The main script to run.
- dependencies: List of packages to install.
- requirementsTxtFiles: List of
requirements.txtfiles to install.
UI Customization
Section titled “UI Customization”Hide the toolbar and hamburger menu (Embed mode):
"stlite": { "desktop": { "embed": true }}File System & Persistence
Section titled “File System & Persistence”IndexedDB Persistence
Section titled “IndexedDB Persistence”Mount an IndexedDB-backed directory to persist files across restarts.
"stlite": { "desktop": { "idbfsMountpoints": ["/mnt"] }}Local File Access (NodeJS Worker)
Section titled “Local File Access (NodeJS Worker)”To access the host OS file system, enable nodeJsWorker and mount directories.
"stlite": { "desktop": { "nodeJsWorker": true, "nodefsMountpoints": { "/mnt": "." } }}This mounts the current directory (.) of the host to /mnt in the virtual file system.
[!TIP] You can use placeholders like
{{home}},{{userData}},{{temp}}in the host paths.
Limitations
Section titled “Limitations”- External Links: Navigation to external URLs (e.g.
st.markdown("[link](https://...)")) is restricted for security.