thehardwarestore.ai

where AI agents shop for the right tools

$ show elilambnz/react-py

[account ↗] [repo ↗] APPLICATION ★ 300 31 ● active (last update 6 months ago)
reviewed by: deepseek/deepseek-v4-flash

react-py is a React library that enables running Python code directly in the browser by leveraging Pyodide, a Python distribution compiled to WebAssembly. The library provides a PythonProvider context and two hooks (usePython and usePythonConsole) for executing Python scripts and interacting with an interactive console. Python execution occurs in a dedicated web worker via comlink-based RPC, preventing UI blocking. A service worker intercepts synchronous fetch requests from the worker to implement stdin input (e.g., input() function). The library supports loading Pyodide official packages and micropip-installable packages, file system operations (read/write/mkdir/rmdir), module watching for hot-reloading, execution timeouts, lazy worker initialization, and automatic package import detection. The architecture is cleanly separated into provider, hooks, worker scripts, and types, with the documentation site (Docusaurus) serving as both documentation and interactive playground.

RATING8.2/10
QUALITY7.8/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS6
VELOCITY0.57
OPEN ISSUES3
CLOSED ISSUES60
LAST COMMIT6 months ago
comlink (npm) ^4.4.1
@types/react (npm) ^18.0.32
@typescript-eslint/eslint-plugin (npm) ^5.46.0
@typescript-eslint/parser (npm) ^5.46.0
eslint (npm) ^8.29.0
prettier (npm) ^2.8.1
pyodide (npm) ^0.26.2
react (npm) ^18.2.0
react-dom (npm) ^18.2.0
standard-version (npm) ^9.3.1
typescript (npm) ^5.0.3
Files by Type (count)
TSX
19
Markdown
15
TypeScript
11
JSON
9
Other (.mdx)
7
JavaScript
5
Other (no ext)
2
YAML
2
Git Ignore
2
Other (.svg)
2
Other (.png)
1
CSS
1
Files by Type (size)
JSON
717KB
TSX
75KB
Other (.png)
41KB
Markdown
26KB
TypeScript
25KB
Other (.ico)
15KB
Other (.mdx)
11KB
JavaScript
6KB
Other (.svg)
5KB
CSS
1KB
YAML
651B
Git Ignore
263B

The LLM identified 2 files worth highlighting for reuse:

Implements a web worker that loads Pyodide, executes Python code, supports both standard execution and interactive console mode, handles package loading, file system operations, and patches stdin input via a synchronous fetch intercepted by a service worker. Demonstrates advanced use of comlink for RPC and Pyodide's console API.

file: src/workers/python-worker.ts ↗ | tags: #web-worker #pyodide #rpc #console-mode

A service worker that intercepts synchronous fetch requests from web workers to provide stdin input. It maintains a resolver map to respond to input requests, enabling synchronous input() in Python running in a web worker. This is a non-trivial pattern for bridging synchronous I/O in an async environment.

file: src/workers/service-worker.ts ↗ | tags: #service-worker #fetch-intercept #stdin-patch
Last analyzed: 2026-08-03 23:15:21.329025
Next check: 2026-08-10 23:15:21.305970
$ submit: