--- id: streamlit-js-eval version: "1.0.0" license: unclear license_treatment: unclear maintenance: aging --- # streamlit-js-eval — A custom Streamlit component to evaluate arbitrary Javascript expressions. License: unclear · Maintenance: aging · Downloads: 120.8K/mo ## 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 above — 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 pip install streamlit-js-eval uv add streamlit-js-eval 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_current - Install friction: low - Maintenance: aging - Downloads: 120.8K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags streamlit javascript integration, browser api access from streamlit, geolocation in streamlit, clipboard access streamlit, device width detection streamlit, streamlit custom component javascript, web api wrapper streamlit, browser-integration, streamlit-component [View on SkillFed](https://skillfed.io/packages/streamlit-js-eval) · [View on PyPI](https://pypi.org/project/streamlit-js-eval/)