Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
78d5717
Phase 1: Update documentation and CHANGELOG for Pro feature separation
AbanoubGhadban Oct 23, 2025
bb35666
Phase 2: Move RSC configuration options to Pro gem
AbanoubGhadban Oct 23, 2025
e346593
Phase 3: Move RSC utility methods to Pro gem
AbanoubGhadban Oct 23, 2025
a978ea6
Add comprehensive tests for Phase 3 RSC utility methods
AbanoubGhadban Oct 23, 2025
4c02413
Add .fuse_hidden* to .gitignore for Claude Code local settings
AbanoubGhadban Oct 23, 2025
dc2b035
Fix rsc_support_enabled? to return explicit boolean values
AbanoubGhadban Oct 23, 2025
bc8716d
Phase 4: Move streaming helper methods to Pro gem
AbanoubGhadban Oct 23, 2025
18d19eb
Fix: Update RSC config references in server_rendering_js_code.rb
AbanoubGhadban Oct 23, 2025
bb20cd7
Fix: Update RSC bundle tests to mock Pro configuration correctly
AbanoubGhadban Oct 23, 2025
b4acd73
Fix: Disable RuboCop VerifiedDoubles check for Pro config mock
AbanoubGhadban Oct 23, 2025
c39127c
Fix: Properly stub ReactOnRailsPro module with configuration method
AbanoubGhadban Oct 23, 2025
ec3517d
Fix: Simplify rsc_support_enabled? method and update related tests
AbanoubGhadban Oct 23, 2025
d678ca8
Fix: Stub rsc_support_enabled? method in ReactOnRailsPro module for a…
AbanoubGhadban Oct 23, 2025
f1c1883
linting
AbanoubGhadban Oct 23, 2025
10c54e1
Fix: Stub LicenseValidator for accurate testing in Utils spec
AbanoubGhadban Oct 23, 2025
198eb0b
Fix: Remove unnecessary blank line in configuration_spec.rb
AbanoubGhadban Oct 23, 2025
a377cac
Refactor: Simplify asset path resolution for Pro RSC manifests in Web…
AbanoubGhadban Oct 23, 2025
24fb4bc
linting
AbanoubGhadban Oct 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,4 @@ ssr-generated

# Claude Code local settings
.claude/settings.local.json
.claude/.fuse_hidden*
33 changes: 33 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,39 @@ To migrate to React on Rails Pro:

**Note:** If you're not using any of the Pro-only methods listed above, no changes are required.

- **Pro-Specific Configurations Moved to Pro Gem**: The following React Server Components (RSC) configurations have been moved from `ReactOnRails.configure` to `ReactOnRailsPro.configure`:

- `rsc_bundle_js_file` - Path to the RSC bundle file
- `react_server_client_manifest_file` - Path to the React server client manifest
- `react_client_manifest_file` - Path to the React client manifest

**Migration:** If you're using RSC features, move these configurations from your `ReactOnRails.configure` block to `ReactOnRailsPro.configure`:

```ruby
# Before
ReactOnRails.configure do |config|
config.rsc_bundle_js_file = "rsc-bundle.js"
config.react_server_client_manifest_file = "react-server-client-manifest.json"
config.react_client_manifest_file = "react-client-manifest.json"
end

# After
ReactOnRailsPro.configure do |config|
config.rsc_bundle_js_file = "rsc-bundle.js"
config.react_server_client_manifest_file = "react-server-client-manifest.json"
config.react_client_manifest_file = "react-client-manifest.json"
end
```

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.

- **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:

- `stream_react_component` - Progressive SSR using React 18+ streaming
- `rsc_payload_react_component` - RSC payload rendering

These helpers are now defined exclusively in the `react-on-rails-pro` gem.

### [16.1.1] - 2025-09-24

#### Bug Fixes
Expand Down
33 changes: 12 additions & 21 deletions docs/api-reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,30 +104,21 @@ ReactOnRails.configure do |config|
# you should include a name that matches your bundle name in your Webpack config.
config.server_bundle_js_file = "server-bundle.js"

# When using React on Rails Pro with RSC support enabled, these configuration options work together:
#
# 1. In RORP, set `config.enable_rsc_support = true` in your react_on_rails_pro.rb initializer
#
# 2. The `rsc_bundle_js_file` (typically "rsc-bundle.js") contains only server components and
# references to client components. It's generated using the RSC Webpack Loader which transforms
# client components into references. This bundle is specifically used for generating RSC payloads
# and is configured with the `react-server` condition.
config.rsc_bundle_js_file = "rsc-bundle.js"
################################################################################
# REACT SERVER COMPONENTS (RSC) AND STREAMING CONFIGURATION
################################################################################
#
# 3. The `react_client_manifest_file` contains mappings for client components that need hydration.
# It's generated by the React Server Components Webpack plugin and is required for client-side
# hydration of components.
# 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.
config.react_client_manifest_file = "react-client-manifest.json"
# React Server Components and Streaming SSR are React on Rails Pro features.
# For detailed configuration of RSC and streaming features, see:
# https://github.com/shakacode/react_on_rails/blob/master/react_on_rails_pro/docs/configuration.md
#
# 4. The `react_server_client_manifest_file` is used during server-side rendering with RSC to
# properly resolve references between server and client components.
# Key Pro configurations (configured in ReactOnRailsPro.configure block):
# - rsc_bundle_js_file: Path to RSC bundle
# - react_client_manifest_file: Client component manifest for RSC
# - react_server_client_manifest_file: Server manifest for RSC
# - enable_rsc_support: Enable React Server Components
#
# These files are crucial when implementing React Server Components with streaming, which offers
# benefits like reduced JavaScript bundle sizes, faster page loading, and selective hydration
# of client components.
# 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.
config.react_server_client_manifest_file = "react-server-client-manifest.json"
# See Pro documentation for complete setup instructions.

################################################################################
# SERVER BUNDLE SECURITY AND ORGANIZATION
Expand Down
56 changes: 41 additions & 15 deletions docs/api-reference/view-helpers-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,6 @@ export default (props, _railsContext) => {

---

### cached_react_component and cached_react_component_hash
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to Pro-Only View Helpers section added below


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:

1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
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`:

```erb
<%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
some_slow_method_that_returns_props
end %>
```

---

### rails_context

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`.
Expand Down Expand Up @@ -132,6 +117,47 @@ This is a helper method that takes any JavaScript expression and returns the out

---

## Pro-Only View Helpers

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.

### cached_react_component and cached_react_component_hash

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:

1. The `cache_key` takes the same parameters as any Rails `cache` view helper.
2. The **props** are passed via a block so that evaluation of the props is not done unless the cache is broken.

Example usage:

```erb
<%= cached_react_component("App", cache_key: [@user, @post], prerender: true) do
some_slow_method_that_returns_props
end %>
```

### stream_react_component

Progressive server-side rendering using React 18+ streaming with `renderToPipeableStream`. This enables:

- Faster Time to First Byte (TTFB)
- Progressive page loading with Suspense boundaries
- Better perceived performance

See the [Streaming Server Rendering guide](../building-features/streaming-server-rendering.md) for usage details.

### rsc_payload_react_component

Renders React Server Component (RSC) payloads in NDJSON format for client-side consumption. Used in conjunction with RSC support to enable:

- Reduced JavaScript bundle sizes
- Server-side data fetching
- Selective client-side hydration

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.

---

# More details

See the [lib/react_on_rails/helper.rb](https://github.com/shakacode/react_on_rails/tree/master/lib/react_on_rails/helper.rb) source.
13 changes: 2 additions & 11 deletions lib/react_on_rails/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ def self.configure
end

DEFAULT_GENERATED_ASSETS_DIR = File.join(%w[public webpack], Rails.env).freeze
DEFAULT_REACT_CLIENT_MANIFEST_FILE = "react-client-manifest.json"
DEFAULT_REACT_SERVER_CLIENT_MANIFEST_FILE = "react-server-client-manifest.json"
DEFAULT_COMPONENT_REGISTRY_TIMEOUT = 5000

def self.configuration
Expand All @@ -20,9 +18,6 @@ def self.configuration
# generated_assets_dirs is deprecated
generated_assets_dir: "",
server_bundle_js_file: "",
rsc_bundle_js_file: "",
react_client_manifest_file: DEFAULT_REACT_CLIENT_MANIFEST_FILE,
react_server_client_manifest_file: DEFAULT_REACT_SERVER_CLIENT_MANIFEST_FILE,
prerender: false,
auto_load_bundle: false,
replay_console: true,
Expand Down Expand Up @@ -72,8 +67,8 @@ class Configuration
:server_render_method, :random_dom_id, :auto_load_bundle,
:same_bundle_for_client_and_server, :rendering_props_extension,
:make_generated_server_bundle_the_entrypoint,
:generated_component_packs_loading_strategy, :immediate_hydration, :rsc_bundle_js_file,
:react_client_manifest_file, :react_server_client_manifest_file, :component_registry_timeout,
:generated_component_packs_loading_strategy, :immediate_hydration,
:component_registry_timeout,
:server_bundle_output_path, :enforce_private_server_bundles

# rubocop:disable Metrics/AbcSize
Expand All @@ -90,7 +85,6 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender
i18n_dir: nil, i18n_yml_dir: nil, i18n_output_format: nil, i18n_yml_safe_load_options: nil,
random_dom_id: nil, server_render_method: nil, rendering_props_extension: nil,
components_subdirectory: nil, auto_load_bundle: nil, immediate_hydration: nil,
rsc_bundle_js_file: nil, react_client_manifest_file: nil, react_server_client_manifest_file: nil,
component_registry_timeout: nil, server_bundle_output_path: nil, enforce_private_server_bundles: nil)
self.node_modules_location = node_modules_location.present? ? node_modules_location : Rails.root
self.generated_assets_dirs = generated_assets_dirs
Expand Down Expand Up @@ -119,9 +113,6 @@ def initialize(node_modules_location: nil, server_bundle_js_file: nil, prerender

# Server rendering:
self.server_bundle_js_file = server_bundle_js_file
self.rsc_bundle_js_file = rsc_bundle_js_file
self.react_client_manifest_file = react_client_manifest_file
self.react_server_client_manifest_file = react_server_client_manifest_file
self.same_bundle_for_client_and_server = same_bundle_for_client_and_server
self.server_renderer_pool_size = self.development_mode ? 1 : server_renderer_pool_size
self.server_renderer_timeout = server_renderer_timeout # seconds
Expand Down
Loading
Loading