Skip to content

@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.

Stlite Desktop Banner

Create a package.json file for your new project:

package.json
{
"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:

Terminal window
npm install
# or
yarn install

Create app.py:

app.py
import streamlit as st
st.write("Hello from Stlite Desktop!")

Dump artifacts (prepare build):

Terminal window
npm run dump

Preview:

Terminal window
npm run serve

Distribute:

Terminal window
npm run app:dist

This generates the application files (.app, .exe, etc.) in the dist directory.

Configure your app via the stlite.desktop section in package.json.

"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.txt files to install.

Hide the toolbar and hamburger menu (Embed mode):

"stlite": {
"desktop": {
"embed": true
}
}

Mount an IndexedDB-backed directory to persist files across restarts.

"stlite": {
"desktop": {
"idbfsMountpoints": ["/mnt"]
}
}

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.

  • External Links: Navigation to external URLs (e.g. st.markdown("[link](https://...)")) is restricted for security.