Reflex Web Framework

0.8.28.post1 · active · verified Thu Apr 16

Reflex is a full-stack web framework that allows developers to build web applications entirely in Python. It automatically generates a React-based frontend and manages backend logic, routing, and state. Currently at version 0.8.28.post1, Reflex maintains a rapid release cadence, frequently pushing new features and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This example creates a simple counter application. Save the code to a file (e.g., `your_app_name.py`). In your terminal, navigate to the directory containing the file. Run `reflex init` to initialize the project, then `reflex run` to start the development server. Access the app in your browser at `http://localhost:3000`.

import reflex as rx

class State(rx.State):
    count: int = 0

    def increment(self):
        self.count += 1

    def decrement(self):
        self.count -= 1

def index():
    return rx.center(
        rx.vstack(
            rx.heading(State.count, size="9"),
            rx.hstack(
                rx.button(
                    "Decrement",
                    color_scheme="red",
                    on_click=State.decrement,
                ),
                rx.button(
                    "Increment",
                    color_scheme="green",
                    on_click=State.increment,
                ),
            ),
            spacing="5",
        ),
        width="100vw",
        height="100vh",
    )

app = rx.App(state=State)
app.add_page(index, route="/")

view raw JSON →