Class: HelloServerController

Inherits:
ApplicationController
  • Object
show all
Includes:
ReactOnRailsPro::Stream
Defined in:
lib/generators/react_on_rails/templates/rsc/base/app/controllers/hello_server_controller.rb

Overview

HelloServer Controller - React Server Components This controller demonstrates how to render RSC pages with streaming SSR. It’s the RSC counterpart to HelloWorldController.

ReactOnRailsPro::Stream provides:

  • stream_view_containing_react_components: Streams the view with RSC support

  • Streaming HTML chunks as components render

  • Automatic hydration on the client

For more information, see: www.shakacode.com/react-on-rails-pro/docs/react-server-components/

Instance Method Summary collapse

Instance Method Details

#indexObject



18
19
20
21
22
23
24
# File 'lib/generators/react_on_rails/templates/rsc/base/app/controllers/hello_server_controller.rb', line 18

def index
  @hello_server_props = {
    name: "React on Rails Pro"
  }

  stream_view_containing_react_components(template: "hello_server/index")
end