# Reflex

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

- Category: App UIs & Builders / Data App Builders
- Language: Python
- Repository: https://github.com/reflex-dev/reflex
- Website: https://reflex.dev
- Canonical page: https://ai-tldr.dev/tools/reflex/

## In short

Reflex is a Python library for building full-stack web apps without leaving Python. It sits in the Data App Builders category of the App UIs & Builders tools and is open-source, written in Python. To get started: create a project and run the dev server.

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

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

```bash
mkdir my_app_name
cd my_app_name
uv init

uv add reflex
uv run reflex init
uv run reflex run
```

2. Edit your app

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

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

```python
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")
```

## 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
