Streamlit component that allows you to do X
uv pip install streamlit-custom-componentWhen developing this component locally, install it in editable mode so Streamlit picks up code changes without rebuilding a wheel. Run this from the directory that contains pyproject.toml:
uv pip install -e . --force-reinstallimport streamlit as st
from my_component import my_component
value = my_component()
st.write(value)To package this component for distribution:
-
Build the frontend assets (from
my_component/frontend):npm i npm run build
-
Build the Python wheel using UV (from the project root with
pyproject.toml):uv run --with build python -m build --wheel
This will create a dist/ directory containing your wheel. The wheel includes the compiled frontend from my_component/frontend/build.
- Python >= 3.10
- Node.js >= 24 (LTS)
dist/streamlit_custom_component-0.0.1-py3-none-any.whl- If you run
uv run --with build python -m build(without--wheel), you’ll also get an sdist:dist/streamlit-custom-component-0.0.1.tar.gz