Skip to content

A custom Streamlit component (React-based) that executes code in the user's browser (like fetch requests) and returns the result to the Python backend.

License

Notifications You must be signed in to change notification settings

doorbis/streamlit-browser-fetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

streamlit-browser-fetch

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.

Why use this?

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).

Installation

Currently, this component is distributed as source. Copy the browser_fetch.py file and the build/ directory into your Streamlit project.

Usage

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.

About

A custom Streamlit component (React-based) that executes code in the user's browser (like fetch requests) and returns the result to the Python backend.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors