Interface ReactDevConfiguration


@Requires(env="dev") @Requires(property="micronaut.views.react.dev.enabled",value="true") @ConfigurationProperties("micronaut.views.react.dev") public interface ReactDevConfiguration
Refreshing the browser when the React server bundle is rebuilt.

micronaut-views-react already reloads the bundle in process: it watches the file, drops its pool of GraalJS contexts, and the next render uses the rebuild. Nothing told the browser, so the refresh was still manual. This module closes that gap.

Two things have to be true before any of it is registered. The application must be running in the "dev" environment, and micronaut.views.react.dev.enabled must be set -- config/application-dev.toml is the natural home for it. Declare the module itself as a development-only dependency so it is not on the classpath of a production build at all.

  • Field Details

  • Method Details

    • isEnabled

      @Bindable(defaultValue="false") boolean isEnabled()
      Whether to tell the browser when the server bundle has been rebuilt.

      Off by default. It serves an unauthenticated endpoint and adds a script to every rendered page, so it has to be asked for rather than inferred.

      Returns:
      whether browser refresh on rebuild is enabled. Defaults to false.
    • getPath

      @NonNull @Bindable(defaultValue="/micronaut/views/react/dev-reload") @NonNull String getPath()
      Returns:
      the path that both transports are served from, and that the injected script connects to. Defaults to "/micronaut/views/react/dev-reload".
    • getQuietPeriod

      @NonNull @Bindable(defaultValue="1s") @NonNull Duration getQuietPeriod()
      How long to wait for bundle writes to settle before telling the browser.

      This is not politeness, it is correctness. The file watcher fires when the bundler starts writing, and micronaut-views-react only drops its cached bundle then -- it re-reads lazily, on the next render. Announce immediately and the browser reloads within milliseconds, that render re-reads a half-written file, and the stale content is cached as the new bundle. The page then sits there with old markup and a current token. Measured in a real browser.

      Waiting for a quiet period means the first render after a rebuild happens once the bundler has finished, so it reads the finished file.

      Returns:
      the quiet period. Defaults to "1s".