A custom Streamlit component that allows you to execute fetch requests and other JavaScript logic directly in the user's browser, returning the result to your Python backend.
Streamlit logic executes entirely on the server. This component solves common limitations by allowing you to:
- Access browser-only data (Local Storage, Session Storage).
- Bypass server-side network bottlenecks by fetching third-party APIs from the client.
- Detect precise browser environment details (Timezones, Language settings).
Currently, this component is distributed as source. Copy the browser_fetch.py file and the build/ directory into your Streamlit project.
import streamlit as st
from browser_fetch import browser_fetch
# Perform a client-side fetch request
result = browser_fetch(
url="[https://api.example.com/data](https://api.example.com/data)",
method="GET",
headers={"Authorization": "Bearer token"}
)
if result:
st.write("Data received from browser:", result)
## Development
To modify the frontend component:
Navigate to the root directory.
Install dependencies: npm install
Start the dev server: npm start
Build for production: npm run build
## License
Copyright (c) 2025 Kossel IP LLC. Licensed under the MIT License.