AI/TLDR

Reflex

Build full-stack web apps in pure Python, frontend and backend

Overview

Reflex is a Python library for building full-stack web apps without leaving Python. You write both the frontend UI and the backend logic as Python code; Reflex handles the React frontend and the Python backend for you, so there is no need to write JavaScript.

It is aimed at Python developers who want to ship a web interface for their data, models, or internal tools but don't want to manage a separate JavaScript stack. You describe components with functions like rx.vstack and rx.button, and keep app data in a state class that updates the UI as it changes.

As a data app builder, Reflex sits alongside tools for turning Python scripts into interactive web apps. It is easy to start with for small apps and is designed to scale up to more complex, full-stack projects.

What it does

  • Write the entire app, frontend and backend, in pure Python with no JavaScript required
  • Components are Python functions (rx.vstack, rx.heading, rx.input, rx.button, rx.image) that compile to a React frontend
  • State lives in a class extending rx.State, and event handlers decorated with @rx.event update the UI
  • Async event handlers let you call external services, such as an image model, and stream updates back to the page
  • Fast refresh in the dev server shows code changes instantly on save
  • Pages are registered with app.add_page, including a page title for the browser tab

Getting started

Reflex recommends a virtual environment so the reflex command is on your PATH. The quickstart below uses uv to create a project, add Reflex, and start the dev server.

Create a project and run the dev server

Make a project folder, initialize it with uv, add Reflex, then init and run the app. You should see it at http://localhost:3000.

bashbash
mkdir my_app_name
cd my_app_name
uv init

uv add reflex
uv run reflex init
uv run reflex run

Edit your app

Modify the source in my_app_name/my_app_name.py. Reflex has fast refresh, so saved changes show up instantly.

Build a page with state

Define UI with component functions, keep data in a class that extends rx.State, update it from @rx.event handlers, and register the page with app.add_page.

pythonpython
import reflex as rx

class State(rx.State):
    prompt: str = ""

    @rx.event
    def set_prompt(self, value: str):
        self.prompt = value

def index():
    return rx.vstack(
        rx.heading("Hello Reflex"),
        rx.input(placeholder="Type here...", on_change=State.set_prompt),
        rx.text(State.prompt),
    )

app = rx.App()
app.add_page(index, title="Reflex App")

Commands and code are distilled from the project's own documentation — always check the official repo for the latest.

When to use it

  • Build an internal tool or dashboard as a web app without setting up a separate JavaScript frontend
  • Put a web UI in front of a Python machine learning model, such as an image generation app driven by an event handler
  • Prototype a full-stack app quickly and grow it into a more complex application over time
  • Let a Python team ship and maintain a web frontend using only skills they already have

How Reflex compares

Reflex alongside other open-source data app builders tools AI/TLDR tracks, ranked by GitHub stars.

ToolStarsWhat it does
Streamlit★ 45kA Python framework that turns scripts into interactive data and ML web apps with simple widget calls and no frontend code.
Gradio★ 43kA Python library for quickly building shareable web demos and UIs for machine learning models, APIs, and arbitrary functions.
Reflex★ 28.6kBuild full-stack web apps in pure Python, frontend and backend
Dash★ 24.3kA Python framework from Plotly for building analytical web dashboards and data apps with interactive charts and no JavaScript required.
marimo★ 21.5kA reactive Python notebook stored as plain Python that can be run as a script or deployed as an interactive data app.
NiceGUI★ 15.9kA backend-first Python UI framework built on FastAPI and Vue for creating web interfaces, dashboards, and internal tools.
Data Formulator★ 15.8kA Microsoft Research tool that combines a UI with AI to help users create rich data visualizations through natural language and direct manipulation.
Mesop★ 6.6kA Python UI framework, started at Google, for rapidly building AI demos and internal web apps using composable components.