@@ -9,10 +9,111 @@ This initial scaffold covers:
99- package metadata and tooling
1010- Django settings-backed configuration
1111- safe JSON and HTML output helpers
12+ - ` django-rspack ` integration helpers for bundle tags and asset lookup
1213- client-only component rendering
14+ - server-side rendering over the shared node renderer protocol
15+ - streaming SSR and RSC response adapters
1316- Django template tags for ` react_component ` and ` react_component_hash `
17+ - store hydration helpers via ` redux_store ` and ` redux_store_hydration_data `
18+ - a ` server_render_js ` helper for raw node-side evaluation
1419- pytest coverage for the initial API surface
1520
16- ` django-rspack ` is intentionally kept at the boundary for now. The rendering
17- core does not assume a specific asset loader yet, so we can plug in the bundler
18- without rewriting the component API.
21+ ## Example app
22+
23+ The repository now includes a runnable Django example at ` example/ ` . It ports
24+ the supported client-rendering slice of ` react_on_rails_pro/spec/dummy ` and
25+ now also exercises the live SSR, streaming, and RSC adapters.
26+
27+ - the client-side HelloWorld page
28+ - the ` server_render_js ` page for non-React server evaluation
29+ - the ` react_component_hash ` metadata page
30+ - a multi-component index page
31+ - the shared-store pages for deferred and server-rendered hydration
32+ - the HTML options example, including JSON-string props and nested ` data-* ` attributes
33+
34+ The example uses ` django-rspack ` for manifest-backed asset lookup and the shared
35+ ` react-on-rails ` npm runtime for browser mounting and hydration.
36+
37+ Run the main validation paths with:
38+
39+ ``` bash
40+ cd example && npm install
41+ ./bin/test-ci
42+ ./bin/dev dev
43+ ./bin/dev static
44+ ./bin/prod
45+ ```
46+
47+ Useful routes in the example app:
48+
49+ - ` / `
50+ - ` /client_side_hello_world/ `
51+ - ` /server_side_hello_world/ `
52+ - ` /server_side_hello_world_shared_store/ `
53+ - ` /server_render_js_example/ `
54+ - ` /metadata_example/ `
55+ - ` /streaming_hello_world/ `
56+ - ` /rsc_hello_world/ `
57+ - ` /client_side_hello_world_with_options/ `
58+
59+ The Python package also exposes the helper APIs directly:
60+
61+ ``` python
62+ from react_on_django import (
63+ redux_store,
64+ redux_store_hydration_data,
65+ render_react_component,
66+ render_react_component_hash,
67+ server_render_js,
68+ )
69+ ```
70+
71+ The Django app now also ships management commands for starter scaffolding:
72+
73+ ``` bash
74+ python manage.py react_install
75+ python manage.py react_generate dashboard-card
76+ python manage.py react_generate posts-feed --rsc
77+ ```
78+
79+ ## Using with django-rspack
80+
81+ ` react-on-django ` uses ` django-rspack ` for compiled asset lookup. The component
82+ renderer stays separate from the bundler, but React on Django exposes helpers so
83+ the two packages fit together cleanly.
84+
85+ ``` python
86+ # settings.py
87+ INSTALLED_APPS = [
88+ ... ,
89+ " django_rspack" ,
90+ " react_on_django" ,
91+ ]
92+
93+ REACT_ON_DJANGO = {
94+ " bundle_name" : " application" ,
95+ }
96+ ```
97+
98+ ``` django
99+ {% load react %}
100+ <!DOCTYPE html>
101+ <html>
102+ <head>
103+ {% react_component_assets %}
104+ </head>
105+ <body>
106+ {% react_component "HelloWorld" props=hello_props %}
107+ </body>
108+ </html>
109+ ```
110+
111+ The integration helpers are also available from Python:
112+
113+ ``` python
114+ from react_on_django.assets import (
115+ get_react_bundle_urls,
116+ get_server_bundle_path,
117+ render_react_component_assets,
118+ )
119+ ```
0 commit comments