Learn more about using islands in your CMS React projects to add a layer of interactivity to your React modules.
Island
from @hubspot/cms-components
.?island
to the end of the import URL.Island
component, passing the module name into the module
prop.Island
component.Island
component props.
Parameter | Type | Description |
---|---|---|
clientOnly | Boolean | When set to true , the island won’t be rendered on the server. This can be useful for components that rely on logic or libraries that can only run in the browser. Default is false . |
hydrateOn | "load" (default) | "visible" | "idle" | Specifies the type of type of hydration to use. When rendering a page with islands on the server, the output includes a script to initialize islands on the client. Hydrating means downloading and initializing the island component code, so using these different hydration types strategically to defer some of that work can help boost initial page load performance. |
id | String | By default, HubSpot generates a unique ID for each island (e.g., island-1234 ). Use this prop to specify your own island ID. |
module | React.Component | The component to wrap. The component must include ?island at the end of the import URL. |
wrapperTag | String | The HTML tag used as the wrapper. Must be a valid HTML element tag (e.g., "span" , "article" , or "section" ). Default is "div" . |
wrapperClassName | String | A class name to pass to the wrapper. |
wrapperStyle | CSSProperties | Inline CSS properties to apply to the wrapper. |
wrapper | React.Component | Wraps the React tree of the Island component to provide custom context. This can be useful for integrating with CSS-in-JS libraries, such as styled-components, or other context providers that need to encapsulate the component’s subtree for applying styles or context values. When using this prop, the component import URL must include a ?client suffix to ensure that it’s bundled for the client (similar to importing with the ?island suffix). |
hydrateOn
prop, you can specify one of the following hydration behaviors:
load
(default): hydrates the island on initial page load.idle
: defers hydration by using the requestIdleCallback method. This can be useful for lower priority components, allowing client resources to be used first on higher priority items.visible
: hydration won’t occur until the element is visible on screen by using the Intersection Observer API. This can be useful for components that aren’t immediately visible to the user on page load (i.e., elements farther down the page). For complex islands, this can provide a significant performance benefit: if the user never scrolls to see the island, it will never be loaded.