You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move Pro-specific utilities and configurations to Pro gem (#1875)
Migrates React Server Components (RSC) and streaming SSR functionality from
the open-source gem to the Pro gem, establishing clear separation between
free and commercial features.
Changes:
- Phase 1: Updated documentation to reflect Pro-only RSC/streaming features
- Phase 2: Moved RSC configs to ReactOnRailsPro.configure block
- Phase 3: Migrated RSC utility methods to ReactOnRailsPro::Utils
- Phase 4: Moved streaming helper methods to ReactOnRailsPro::Helper
Copy file name to clipboardExpand all lines: CHANGELOG.md
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,6 +73,39 @@ To migrate to React on Rails Pro:
73
73
74
74
**Note:** If you're not using any of the Pro-only methods listed above, no changes are required.
75
75
76
+
-**Pro-Specific Configurations Moved to Pro Gem**: The following React Server Components (RSC) configurations have been moved from `ReactOnRails.configure` to `ReactOnRailsPro.configure`:
77
+
78
+
-`rsc_bundle_js_file` - Path to the RSC bundle file
79
+
-`react_server_client_manifest_file` - Path to the React server client manifest
80
+
-`react_client_manifest_file` - Path to the React client manifest
81
+
82
+
**Migration:** If you're using RSC features, move these configurations from your `ReactOnRails.configure` block to `ReactOnRailsPro.configure`:
See the [React on Rails Pro Configuration docs](https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/docs/configuration.md) for more details.
101
+
102
+
-**Streaming View Helpers Moved to Pro Gem**: The following view helpers have been removed from the open-source gem and are now only available in React on Rails Pro:
103
+
104
+
-`stream_react_component` - Progressive SSR using React 18+ streaming
# 3. The `react_client_manifest_file` contains mappings for client components that need hydration.
118
-
# It's generated by the React Server Components Webpack plugin and is required for client-side
119
-
# hydration of components.
120
-
# This manifest file is automatically generated by the React Server Components Webpack plugin. Only set this if you've configured the plugin to use a different filename.
# 4. The `react_server_client_manifest_file` is used during server-side rendering with RSC to
124
-
# properly resolve references between server and client components.
115
+
# Key Pro configurations (configured in ReactOnRailsPro.configure block):
116
+
# - rsc_bundle_js_file: Path to RSC bundle
117
+
# - react_client_manifest_file: Client component manifest for RSC
118
+
# - react_server_client_manifest_file: Server manifest for RSC
119
+
# - enable_rsc_support: Enable React Server Components
125
120
#
126
-
# These files are crucial when implementing React Server Components with streaming, which offers
127
-
# benefits like reduced JavaScript bundle sizes, faster page loading, and selective hydration
128
-
# of client components.
129
-
# This manifest file is automatically generated by the React Server Components Webpack plugin. Only set this if you've configured the plugin to use a different filename.
### cached_react_component and cached_react_component_hash
84
-
85
-
Fragment caching is a [React on Rails Pro](https://github.com/shakacode/react_on_rails/wiki) feature. The API is the same as the above, but for 2 differences:
86
-
87
-
1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
88
-
1. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken. Suppose you put your props calculation into some method called `some_slow_method_that_returns_props`:
89
-
90
-
```erb
91
-
<%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
92
-
some_slow_method_that_returns_props
93
-
end %>
94
-
```
95
-
96
-
---
97
-
98
83
### rails_context
99
84
100
85
You can call `rails_context` or `rails_context(server_side: true|false)` from your controller or view to see what values are in the Rails Context. Pass true or false depending on whether you want to see the server-side or the client-side `rails_context`. Typically, for computing cache keys, you should leave `server_side` as the default true. When calling this from a controller method, use `helpers.rails_context`.
@@ -132,6 +117,47 @@ This is a helper method that takes any JavaScript expression and returns the out
132
117
133
118
---
134
119
120
+
## Pro-Only View Helpers
121
+
122
+
The following view helpers are available exclusively with [React on Rails Pro](https://www.shakacode.com/react-on-rails-pro). These require a valid React on Rails Pro license and will not be available if the Pro gem is not installed or properly licensed.
123
+
124
+
### cached_react_component and cached_react_component_hash
125
+
126
+
Fragment caching helpers that cache React component rendering to improve performance. The API is the same as `react_component` and `react_component_hash`, but with these differences:
127
+
128
+
1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
129
+
2. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken.
130
+
131
+
Example usage:
132
+
133
+
```erb
134
+
<%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
135
+
some_slow_method_that_returns_props
136
+
end %>
137
+
```
138
+
139
+
### stream_react_component
140
+
141
+
Progressive server-side rendering using React 18+ streaming with `renderToPipeableStream`. This enables:
142
+
143
+
- Faster Time to First Byte (TTFB)
144
+
- Progressive page loading with Suspense boundaries
145
+
- Better perceived performance
146
+
147
+
See the [Streaming Server Rendering guide](../building-features/streaming-server-rendering.md) for usage details.
148
+
149
+
### rsc_payload_react_component
150
+
151
+
Renders React Server Component (RSC) payloads in NDJSON format for client-side consumption. Used in conjunction with RSC support to enable:
152
+
153
+
- Reduced JavaScript bundle sizes
154
+
- Server-side data fetching
155
+
- Selective client-side hydration
156
+
157
+
See the [React on Rails Pro Configuration](https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/docs/configuration.md) for RSC setup.
158
+
159
+
---
160
+
135
161
# More details
136
162
137
163
See the [lib/react_on_rails/helper.rb](https://github.com/shakacode/react_on_rails/tree/master/lib/react_on_rails/helper.rb) source.
0 commit comments