ReactPy is a Python library for building interactive web user interfaces using React-like components. Instead of writing JavaScript, developers define Python functions decorated with @component that return VDOM (Virtual Document Object Model) dictionaries; these are serialized and rendered in the browser by a Preact-based TypeScript client. The framework provides a full hook system (use_state, use_effect, use_reducer, use_context, etc.), an event-handling layer supporting debounce, throttle, and live browser-object proxies, and first-class ASGI integration via middleware or standalone ASGI apps. It also supports PyScript/Pyodide for running components entirely in the browser and importing actual ReactJS/NPM components from Python. The architecture is a hybrid library/framework: a Python core package (src/reactpy) handles component lifecycle, layout rendering, event dispatch, and state management, while a separate JavaScript client package (src/js/packages/@reactpy/client) handles DOM rendering and WebSocket communication. A notable design feature is the live event proxy, which avoids serializing entire browser event objects to the server; instead, the client holds event objects and lets Python code lazily read properties or invoke methods over a batched, security-blocklisted protocol. The project is well-tested with unit tests, Playwright-based integration tests, and CI across multiple Python versions and operating systems. It is not a data pipeline or research codebase; data-related content appears only as demo examples. The repository also contains substantial documentation, example galleries, build tooling for both Python and JavaScript, and testing fixtures that are useful for any project needing browser-backed backend testing. Some legacy APIs (e.g., reactpy.web) coexist with newer reactjs-based APIs, and the documentation has areas marked under construction, but the core code is actively maintained and demonstrates strong engineering practices.
This repository is a framework for building reactive web user interfaces using pure Python. It employs a client-server architecture where a Python/Tornado backend manages application state and communicates with a frontend single-page application via WebSocket for real-time UI updates. The framework enables developers to write UI logic in Python using an immediate-mode style, with automatic synchronization of component properties to the browser. Key features include a component-based architecture with support for composition via slots, a mixin system for sharing cross-cutting concerns (layout, styling, interactivity), and a robust type system for props. The frontend leverages Shoelace Web Components and Chart.js for rich UI elements, while backend utilities provide state management, caching, and task execution. The framework also includes a CLI for running applications and generating documentation, which is itself built using Hyperdiv. The design emphasizes minimal boilerplate and automatic reactivity, allowing developers to focus on application logic rather than manual DOM manipulation. Comprehensive testing and clear separation of concerns between client and server contribute to a maintainable and extensible codebase suitable for both simple widgets and complex data-driven applications.