skillfed

streamlit-js-eval

A custom Streamlit component to evaluate arbitrary Javascript expressions.

streamlit-js-eval v1.0.0 120.8K downloads/30d#12,008 on PyPI93
License unclear AGING released

What it is and what it does

Streamlit-js-eval is a custom Streamlit component that bridges Python and the browser by executing arbitrary JavaScript expressions and returning their results. It exposes browser APIs—geolocation, clipboard, device dimensions, user agent, language preferences, and Android sharing—that are either unavailable or cumbersome to access from pure Python Streamlit code. The package includes convenience wrappers for common tasks like `get_geolocation()` and `get_page_location()`, with error handling for permission denials and failures.

You use it by calling `streamlit_js_eval()` with a JavaScript expression string and a unique key, or by invoking pre-built functions for specific browser capabilities. It's useful when your Streamlit app needs to adapt to the user's device or environment—detecting mobile screens, reading cookies, writing to clipboard, or requesting location permission—without leaving the Streamlit framework.

Use it for:

  • Detect whether a user is on a mobile device by checking screen width and adapting the UI layout accordingly.
  • Request and retrieve user geolocation with error handling for permission denial or unavailable position.
  • Copy data to the user's clipboard or read clipboard contents programmatically from a Streamlit app.
  • Access browser metadata like user agent, language preference, or page URL components for analytics or personalization.
  • Implement Android-specific features like the native share sheet in a Streamlit web app.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Streamlit-js-eval lets you run arbitrary JavaScript expressions from a Streamlit app and return their results, enabling access to browser APIs like geolocation, clipboard, device width, and user agent that are unavailable or difficult in pure Python.

Yes, if you need browser API access in Streamlit and accept the maintenance risk. Install friction is low and the package has no known vulnerabilities. However, verify the license terms first (currently unclear), and be aware that maintenance is aging—last release was 217 days ago. The known limitation with st.button in branching contexts may affect some use cases; check whether the bootstrapButton workaround suits your needs.

Install

streamlit-js-eval on PyPI

pip

pip install streamlit-js-eval

uv

uv add streamlit-js-eval

poetry

poetry add streamlit-js-eval

Installing streamlit-js-eval

Before you install

Low friction: pure Python wheel with only streamlit as a runtime dependency. Maintenance status is aging—last commit was 217 days ago, though the repository is still active and not archived.

License in practice

License status is unclear; the package declares no SPDX identifier or raw license text. Verify the actual license terms before use in proprietary or restricted contexts.

Quickstart

pip install streamlit-js-eval

import streamlit as st
from streamlit_js_eval import streamlit_js_eval

width = streamlit_js_eval(js_expressions='screen.width', key='SCR')
st.write(f"Screen width is {width}")

Requires Python >=3.8 and a running Streamlit app; JavaScript execution depends on browser environment, so it only works in deployed or local Streamlit apps, not in headless contexts.

Verify before relying

  • Whether the 'aging' maintenance status (217 days since last release) signals active development or dormancy; repo is not archived but commit frequency is unclear.
  • Actual license terms and any compatibility restrictions, given the unclear license_treatment.
  • Current state of the known limitation with st.button in branching contexts and whether bootstrapButton workaround is stable.

Package facts

License not declared (unclear)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 1 — streamlit
Maintenance aging — 217 days since the last release
Last repo commit
First released
Downloads 120,848/month — #12,008 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: streamlit_js_eval-1.0.0-py3-none-any.whl

Keywords: Python, Streamlit, JavaScript

Tags

streamlit javascript integrationbrowser api access from streamlitgeolocation in streamlitclipboard access streamlitdevice width detection streamlitstreamlit custom component javascriptweb api wrapper streamlit
browser-integrationstreamlit-component

More Dynamic Content packages

MarkupSafe

MarkupSafe provides a text object that escapes…

permissive · top 100 on PyPI

Jinja2

Jinja2 is a templating engine that renders…

permissive · top 100 on PyPI

soupsieve

Soupsieve is a CSS selector library designed to…

permissive · top 100 on PyPI

Werkzeug

Werkzeug is a WSGI utility library providing…

permissive · top 1,000 on PyPI

Flask

Flask is a lightweight WSGI web application…

permissive · top 1,000 on PyPI

Mako

Mako compiles Python-embedded templates into…

permissive · top 1,000 on PyPI

streamlit-autorefresh

Adds a frontend timer to Streamlit apps that…

unclear · top 15,000 on PyPI

streamlit-javascript

Executes arbitrary JavaScript code from within…

permissive · top 15,000 on PyPI

streamlit-cookies-controller

Provides read, write, and delete operations on…

permissive · top 15,000 on PyPI

extra-streamlit-components

Provides additional UI components for Streamlit…

permissive · top 15,000 on PyPI

streamlit-plotly-events

Captures click, select, and hover events from…

unclear · top 15,000 on PyPI

streamlit-pdf-viewer

Streamlit component that renders PDF documents…

unclear · top 15,000 on PyPI

streamlit-avatar

Renders clickable avatar icons with images,…

unclear · top 15,000 on PyPI

streamlit-ace

Embeds an Ace code editor component into…

permissive · top 15,000 on PyPI

st-theme

Detects and returns the active theme (light or…

permissive · top 15,000 on PyPI

streamlit-msal

Adds Microsoft Authentication Library (MSAL)…

unclear · top 15,000 on PyPI