Interface ReactViewsRendererConfiguration
@ConfigurationProperties("micronaut.views.react")
public interface ReactViewsRendererConfiguration
An interface to the configuration properties for React server-side rendering.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value forgetClientBundleURL().static final booleanThe default value forisHydrateWithoutRequest().static final StringThe default value forgetRenderScript().static final StringThe default value forgetServerBundlePath().static final StringThe config key prefix used to configure the React SSR view renderer. -
Method Summary
Modifier and TypeMethodDescription@NotBlank @NonNull String@NotBlank @NonNull Stringboolean@NotBlank @NonNull StringbooleanWhether a render with noHttpRequeststill emits the hydration bootstrap: theMicronautobject carrying the serialised view model, and the script tag for the client bundle.
-
Field Details
-
PREFIX
The config key prefix used to configure the React SSR view renderer.- See Also:
-
DEFAULT_CLIENT_BUNDLE_URL
-
DEFAULT_HYDRATE_WITHOUT_REQUEST
static final boolean DEFAULT_HYDRATE_WITHOUT_REQUESTThe default value forisHydrateWithoutRequest().- See Also:
-
DEFAULT_SERVER_BUNDLE_PATH
The default value forgetServerBundlePath().- See Also:
-
DEFAULT_RENDER_SCRIPT
-
-
Method Details
-
getClientBundleURL
@NotBlank @Bindable(defaultValue="/static/client.js") @NotBlank @NonNull String getClientBundleURL()- Returns:
- the URL (relative or absolute) where the client Javascript bundle can be found. It will be appended to the generated HTML in a <script> tag. Defaults to "/static/client.js"
-
isHydrateWithoutRequest
@Bindable(defaultValue="true") boolean isHydrateWithoutRequest()Whether a render with noHttpRequeststill emits the hydration bootstrap: theMicronautobject carrying the serialised view model, and the script tag for the client bundle.Such a render is not being sent to a browser. An email body built by
micronaut-email-templateis the common case: it cannot hydrate, the bundle URL has no origin to resolve against, and the bootstrap puts the entire model into the delivered message -- a password reset token along with everything else. Set this tofalseto render markup only in that case; a render with a request is unaffected either way.- Returns:
- whether to hydrate a render that has no request. Defaults to true, which is the historical behaviour.
-
getServerBundlePath
@NotBlank @Bindable(defaultValue="classpath:views/ssr-components.mjs") @NotBlank @NonNull String getServerBundlePath()- Returns:
- the path relative to micronaut.views.folder where the bundle used for server-side rendering can be found. Defaults to "classpath:views/ssr-components.mjs"
-
getRenderScript
@NotBlank @Bindable(defaultValue="classpath:io/micronaut/views/react/react.js") @NotBlank @NonNull String getRenderScript()- Returns:
- Either a file path (starting with "file:" or a resource in the classpath (starting with "classpath:") to a render script. Please see the user guide for more information on what this Javascript file should contain.
-
getSandbox
@Bindable(defaultValue="false") boolean getSandbox()- Returns:
- If true, GraalJS sandboxing is enabled. This helps protect you against supply chain attacks that might inject code into your server via hijacked React components. It requires a sufficiently new version of GraalJS. Defaults to OFF.
-