v4 Plugin-Only Migration¶
v4 makes rxconfig.py the integration source of truth. Django settings still hold normal Django configuration, auth branding, sessions, cache, and mirror toggles, but embed/mount/proxy/bridge behavior moves to ReflexDjangoPlugin.
Before¶
Older projects often used settings-driven integration or management commands such as:
After¶
Use rxconfig.py:
import reflex as rx
from reflex_django.plugins import ReflexDjangoPlugin
config = rx.Config(
app_name="shop",
plugins=[
ReflexDjangoPlugin(config={
"settings_module": "config.settings",
"profile": "integrated",
}),
],
)
Use native Reflex commands:
Replacement map¶
| Removed pattern | Use |
|---|---|
manage.py run_reflex |
reflex run |
manage.py export_reflex |
reflex export |
from reflex_django import app |
Create app = rx.App() in {app_name}/{app_name}.py |
RX_PAGE_PACKAGES |
Register pages with app.add_page(...), or use @page in {app_name}/views.py |
settings-driven RX_CONFIG / RX_PLUGINS |
ReflexDjangoPlugin(config={...}) in rxconfig.py |
IntegrationMode and integration installers |
Plugin profiles and pillar blocks |
reflex_mount(..., rx_config=, plugins=) |
URL overrides only; use rxconfig.py for app config |
SPA routes in Django urlpatterns |
Django routes only; Reflex pages live in the Reflex app |
Profiles¶
| Profile | Use when |
|---|---|
integrated |
One reflex run; Django is embedded in the Reflex backend during dev |
split_dev |
Django runserver plus reflex run; Vite proxies Django paths |
reflex_only |
Reflex UI only; no Django HTTP embedding |
You can override individual pillars after choosing a profile:
ReflexDjangoPlugin(config={
"settings_module": "config.settings",
"profile": "integrated",
"bridge": {"mode": "smart"},
"mount": {"django_prefix": ("/admin", "/api")},
})
Page migration¶
Create {app_name}/{app_name}.py:
Do not add Reflex SPA routes to Django urlpatterns. Keep Django routes such as admin and APIs in urls.py; the mount layer handles the SPA catch-all.
Checklist¶
- Add
ReflexDjangoPlugintorxconfig.py. - Move integration profile/pillar configuration out of Django settings.
- Create
{app_name}/{app_name}.pywithapp = rx.App(). - Register pages with
app.add_page(...)or@pagein{app_name}/views.py. - Replace
manage.py run_reflexwithreflex run. - Replace
manage.py export_reflexwithreflex export. - Keep
reflex_djangoinINSTALLED_APPSandAsyncStreamingMiddlewarelast inMIDDLEWARE. - Run your app and check Django-owned paths (
/admin/,/api/) plus Reflex pages fromhttp://localhost:3000/.
Next: Integration, Config reference, and Troubleshooting.