$ account elilambnz
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.