Skip to main content

streamlit-js

Streamlit component that allows you to run JS code with both blocking and non-blocking modes.

The package is based on the streamlit-javascript.

The main difference is that the package above doesn't allow distinguishing if the JS code is executed or not in all situations (e.g. when the code returns null).

It's important because Streamlit components works in asyncronous mode and cannot return value immediately. They need several reruns to get the value. So, it's important to know when the code is finished and when it's not.

This package solves this issue by returning [] when the code is not finished and [None] when the code is finished and returns null. Also, it allows to block the script until the JS code is executed and app is refreshed.

Installation instructions

pip install streamlit-js

Usage instructions

import streamlit as st

from streamlit_js import st_js, st_js_blocking

value = st_js(code='return null;')
if not value:
    st.write('Loading...')
    st.stop()
st.write(value) # [None]
st.write(value[0] # None

# This will block the script until the js code is executed
value = st_js_blocking(code='return null;')
st.write(value) # None

Release files for streamlit-js 1.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-js 1.0.8
File Size Uploaded
streamlit-js-1.0.8.tar.gz 507.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for streamlit-js 1.0.8
File Interpreter ABI Platform
streamlit_js-1.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / streamlit-js-1.0.8.tar.gz

Download URL streamlit-js-1.0.8.tar.gz
Size 507.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f23c1c9ff1a1ca44222a2b24cd6edf84daf6e78f5bbe07dfc87b35f7e7a16526
BLAKE2b-256 checksum
How to use checksums
0877e84aa98cf29572ebc49873b3d6646e4572b9f9f392cbf8b10812ee0c7264
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.0

Release files / streamlit_js-1.0.8-py3-none-any.whl

Download URL streamlit_js-1.0.8-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
05d8447caa87abb123137f62e7e5aeed8ca83015ee170aa829280c7034a23117
BLAKE2b-256 checksum
How to use checksums
d75c65614b858d39c28a1b0ed1690b73da4f6f061fca1d25e757bf56f3226f5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.0.8 This release

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page