Skip to content

reflex-django

Keep Django. Get a reactive UI in Python. Same process, same port, same cookies.

PyPI Python License


Hi, welcome.

You're probably here because you love Django — the ORM, the admin, the migrations, the way it just works — but you also want a modern, reactive frontend without writing React, Vue, or shipping a separate Node app.

That's exactly what reflex-django is for.

You keep writing Django. You write your UI in Python using Reflex. They run as one program, on one port, and your Django session is the same session your buttons see. No CORS, no token gymnastics, no second dev server in another terminal.


What you'll actually write

Three files. That's the whole shape of a reflex-django project:

# config/settings.py — register reflex_django like any other app
INSTALLED_APPS = [..., "reflex_django", "shop"]
# config/urls.py — one line wires Reflex in
from reflex_django.urls import reflex_mount

urlpatterns = [path("admin/", admin.site.urls)]
urlpatterns += [reflex_mount(app_name="shop")]
# shop/views.py — your pages live here, next to your models
import reflex as rx
from reflex_django import template
from reflex_django.state import AppState

class HomeState(AppState):
    @rx.event
    async def on_load(self):
        if self.request.user.is_authenticated:
            self.greeting = f"Hi, {self.request.user.get_username()}!"

@template(route="/", title="Home")
def index() -> rx.Component:
    return rx.heading(HomeState.greeting)

Then:

python manage.py run_reflex

That's it. Open http://localhost:8000/. Your admin is at /admin/. Your reactive UI is at /. They share cookies, sessions, and the same Python process.


Pick a path


A suggested reading order

If you're new and you'd like a guided tour, this is the path most people find easiest:

  1. Why reflex-django exists — the one-page story
  2. How Django works in 5 minutes — skip this if Django is your day job
  3. How Reflex works in 5 minutes — skip this if Reflex is your day job
  4. How the two fit together — the bridge, in plain English
  5. Install and Your first app
  6. The Essentials — pages, state, the database, auth

Then drop into the build guides when you actually need them — CRUD pages, forms, i18n, deployment.


Looking for something specific?

I want to… Read
Configure ports, app name, prefixes Configuration
Put pages next to my Django models Pages live in views.py
Read request.user inside a button handler AppState: your bridge to Django
Build a list/edit/delete page fast CRUD with ModelState
Understand the WebSocket plumbing The WebSocket event pipeline
Deploy to one container Deployment
Look up a REFLEX_DJANGO_* setting Settings reference
See every public symbol Public API at a glance

Next: Why reflex-django exists →