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.
@stlite/desktop turns any Streamlit Python application into a native desktop app powered by Electron and Pyodide. This guide walks you through every step, from an empty directory to a distributable installer, without requiring Python to be installed on your development machine or the end-user’s machine.
Prerequisites
- Node.js 18 or later
- npm (bundled with Node.js) or yarn
Steps
Create package.json
Create a new directory for your project and add the following Key fields to understand:
package.json file. Update the name field to match your application name.| Field | Purpose |
|---|---|
main | Points Electron to the compiled entry file inside build/. Do not change this. |
scripts.dump | Runs the dump-stlite-desktop-artifacts CLI to prepare the build/ directory. |
scripts.serve | Launches Electron against the build/ directory for local preview. |
scripts.app:dist | Packages the app into a distributable installer via electron-builder. |
scripts.postinstall | Installs native Electron dependencies automatically after npm install. |
build.files | Tells electron-builder which files to include in the final package. |
stlite.desktop.files | Your app source files to copy into the bundle. |
stlite.desktop.entrypoint | The Streamlit script that serves as the app’s entry point. |
Install dependencies
Run the install command in your project directory. This downloads Electron, Or, if you prefer yarn:
@stlite/desktop, and all other declared packages.Create app.py
Create The filename
app.py in the same directory and write your Streamlit application code:app.py is referenced in two places in package.json:stlite.desktop.files— tells thedumpcommand to copy this file into the bundle.stlite.desktop.entrypoint— tells Stlite which file to run when the app starts.
Add more files (optional)
You can include additional source files — extra Python modules, data files, images, or multi-page app pages — by adding them to the
stlite.desktop.files array. Glob patterns are supported.For example, to add a multi-page app structure:pages/*.pymatches all Python files in thepages/directory, enabling Streamlit’s multi-page app feature.assetscopies the entireassets/directory into the bundle.
Specify Python packages (optional)
If your app depends on third-party Python packages, declare them so the Option B — Both options can be combined. Packages are downloaded from the Pyodide package registry and pre-bundled so no internet connection is required at runtime.
dump command can pre-install them into the bundle.Option A — inline list in package.json:requirements.txt file:Run the dump command
Generate the Or with yarn:The
build/ directory that contains everything Electron needs:dump command performs the following:- Copies your app source files (as listed in
stlite.desktop.files) intobuild/. - Downloads the Pyodide runtime.
- Downloads and pre-installs any declared Python packages.
- Writes the Electron main process scripts to
build/electron/.
package.json.Preview the app
Launch Electron to preview the app locally before packaging:This runs
cross-env NODE_ENV=production electron ., which starts Electron and loads ./build/electron/main.js. You should see your Streamlit app open in a native desktop window.Package for distribution
When you are ready to distribute, build the final installer:
electron-builder reads your build configuration in package.json and produces platform-specific installers in the ./dist directory:- macOS —
.dmgand/or.app - Windows —
.exeinstaller - Linux —
.AppImage,.deb, or other formats
electron-builder documentation.Keep Electron up to date. Always use the latest stable release of Electron to ensure your app receives security patches. The Electron project lists this as an official security best practice. Update the
electron version in your devDependencies and re-run npm install and npm run dump after upgrading.