Skip to content

Move RSC and streaming utilities and configs from React on Rails to React on Rails Pro #1874

@AbanoubGhadban

Description

@AbanoubGhadban

Overview

Move React on Rails Pro-specific utilities, configurations, and helper methods from the open-source React on Rails gem to the Pro gem. This improves code separation, reduces open-source gem size, and clarifies the distinction between open-source and Pro features.

Key Principle

Keep immediate_hydration in open-source - This Pro feature will remain in the open-source gem with a marketing badge to encourage Pro adoption.

What Moves to Pro Gem

Configuration Options

  • rsc_bundle_js_file - RSC bundle path (Pro-only feature)
  • react_server_client_manifest_file - Server manifest for RSC
  • react_client_manifest_file - Client manifest for RSC

Helper Methods

  • stream_react_component - Streaming SSR helper (Pro-only)
  • rsc_payload_react_component - RSC payload helper (Pro-only)
  • All internal streaming methods (internal_stream_react_component, internal_rsc_payload_react_component, run_stream_inside_fiber, etc.)

Render Options

  • :html_streaming render mode
  • :rsc_payload_streaming render mode
  • raise_non_shell_server_rendering_errors option
  • Streaming-related methods (streaming?, html_streaming?, rsc_payload_streaming?)

Utilities

  • rsc_support_enabled? - RSC detection
  • rsc_bundle_js_file_path - RSC bundle path resolution
  • react_server_client_manifest_file_path - Manifest path resolution
  • RSC pack generation logic (client_entrypoint? detection, registerServerComponent logic)

What Stays in Open-Source

Marketing/Trial Features

  • immediate_hydration config - Shows Pro marketing badge when used without license
  • ProHelper module - Generates Pro warning badges
  • ProUtils module - Pro feature detection

Core Infrastructure (Used by Open-Source SSR)

  • server_bundle_output_path - Used by standard server rendering
  • enforce_private_server_bundles - Security feature for all server bundles
  • component_registry_timeout - Used by core features

Core Functionality

  • react_component, react_component_hash - Core view helpers
  • Standard render modes (:server, :client)
  • Pro detection utilities (react_on_rails_pro?, react_on_rails_pro_version)
  • Server rendering pool delegation logic

Implementation Strategy

Approach: Complete Removal (Option A)

  • Remove Pro-specific code from open-source completely
  • Pro gem implements all streaming/RSC features
  • Clean separation, no code duplication
  • Helpful error messages when Pro features used without license

Phase-by-Phase Implementation (11 Phases)

  1. Update Documentation & CHANGELOG
  2. Move RSC Configuration Options to Pro Gem
  3. Move RSC Utility Methods to Pro Gem
  4. Move Streaming Helper Methods to Pro Gem
  5. Move Internal Streaming Methods to Pro Gem
  6. Move Streaming Render Modes & Options to Pro Gem
  7. Move RSC Pack Generation Logic to Pro Gem
  8. Update Doctor Diagnostics
  9. Update Generator Templates
  10. Update Both Dummy Apps (spec/dummy & react_on_rails_pro/spec/dummy)
  11. Final Cleanup & Verification

Each phase averages ~60 lines of changes for easy review and maintains a working state.

Breaking Changes

For Pro Users

Pro users will need to update their configuration during upgrade:

Before:

ReactOnRails.configure do |config|
  config.rsc_bundle_js_file = "rsc-bundle.js"
  config.react_server_client_manifest_file = "server-manifest.json"
end

After:

ReactOnRailsPro.configure do |config|
  config.rsc_bundle_js_file = "rsc-bundle.js"
  config.react_server_client_manifest_file = "server-manifest.json"
end

For Open-Source Users

  • No breaking changes for standard SSR features
  • Attempting to use Pro features without license will show clear error messages directing to Pro

Benefits

  • Clearer separation - Pro features clearly distinguished from open-source
  • Smaller open-source gem - ~600 lines of Pro-specific code removed
  • Better marketing - immediate_hydration remains as trial feature with badge
  • Maintained security - Server bundle security configs stay in open-source (used by all)
  • Clear errors - Helpful messages when Pro features used without license
  • No code duplication - Single source of truth for each feature

Testing Strategy

  • Verify open-source tests pass without Pro gem (using spec/dummy)
  • Verify Pro tests pass with Pro gem (using react_on_rails_pro/spec/dummy)
  • Test error messages when Pro features used without license
  • Verify immediate_hydration marketing badge displays correctly
  • Test both dummy apps after each phase

Related

  • Part of major version release (version number TBD)
  • Documentation updates will be grouped with other breaking changes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions