Views
Contents
The adapter’s built-in React views turn a normalized XP page tree into React elements. Each file below is a separate entry point under @enonic/nextjs-adapter/views/; import the default or named export from the file that defines it.
Most applications call only MainView. The remaining views form its rendering pipeline and are useful when replacing or composing the default behavior.
Usage
import MainView from '@enonic/nextjs-adapter/views/MainView';
import Regions, {RegionView} from '@enonic/nextjs-adapter/views/Region';
import RichTextView from '@enonic/nextjs-adapter/views/RichTextView';
MainView accepts the complete result from fetchContent():
const result = await fetchContent({contentPath, locale});
return <MainView {...result}/>;
Mapped page, layout, part, and macro views do not receive the built-in views' input objects. The adapter resolves each component first and passes the mapping-specific props documented under Type Definitions.
Functions
MainView
Main rendering entry point. It renders SingleComponent for a Content Studio component request and otherwise delegates to BaseContent.
Parameters
MainView() takes a single props object with the FetchContentResult properties.
Returns
JSX.Element.
BaseContent
Chooses the registered content-type view for meta.type. If no explicit content-type view takes precedence, it delegates to the page descriptor through BasePage; a catch-all content-type view is the final fallback.
Parameters
BaseContent() takes a single props object with the FetchContentResult properties.
Returns
JSX.Element.
BasePage
Resolves an XP page descriptor in ComponentRegistry and renders the registered view with PageProps. In development or Content Studio it can render a missing-component or error view instead.
Parameters
BasePage() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Optional. Normalized page descriptor, configuration, template, and regions. |
|
|
|
|
Optional. Path of the page component in the XP page tree. |
|
|
|
Optional. Processed result of the shared query. |
|
|
|
Optional. Processed result of the page mapping’s query. |
|
|
|
Optional. Error produced while resolving the page. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
BaseLayout
Resolves an XP layout descriptor in ComponentRegistry, normalizes its regions, and renders the registered layout view with LayoutProps.
Parameters
BaseLayout() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Optional. Normalized layout descriptor and configuration. |
|
|
|
|
Path of the layout component in the XP page tree. |
|
|
Optional. Regions belonging to the layout. |
|
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
BasePart
Resolves an XP part descriptor in ComponentRegistry and renders the registered part view with PartProps.
Parameters
BasePart() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Optional. Normalized part descriptor, configuration, and queried fields. |
|
|
|
|
Path of the part component in the XP page tree. |
|
|
|
Optional. Processed result of the shared query. |
|
|
|
Optional. Processed result of the part mapping’s query. |
|
|
|
Optional. Error produced while resolving the part. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
BaseComponent
Dispatches one normalized component to the registered component-kind view, such as BasePage, BaseLayout, BasePart, or Text. In edit mode it also adds the data-portal-component-type annotation expected by Content Studio.
Parameters
BaseComponent() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Normalized component containing its type, tree path, component data, and optional processed data. |
|
|
|
Runtime request and editing context. |
|
|
|
|
Optional. Processed result of the shared query. |
Returns
JSX.Element.
BaseMacro
Resolves a rich-text macro in ComponentRegistry. In edit mode it preserves macro syntax unless renderInEditMode is enabled; macro configuration values are normalized before reaching the mapped view.
Parameters
BaseMacro() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
|
Content enclosed by the macro. |
|
|
|
Macro name, descriptor, and Guillotine configuration. |
|
|
Runtime request and editing context. |
|
|
|
|
Optional. Render the mapped macro inside Content Studio instead of preserving its source syntax. Default: |
Returns
JSX.Element.
Region
The default export from views/Region, imported under any local name such as Regions. It renders every region on a page, or one region selected by name.
Parameters
Region() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
PageData or |
Page containing the regions to render. |
|
|
|
Optional. Render only the region with this name. |
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
RegionView
Named export from views/Region. It renders one region, orders its components by their numeric component-path index, and adds the data-portal-region annotation in edit mode.
Parameters
RegionView() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
|
XP region name. |
|
|
PageComponent`[]` |
Optional. Components in the region. |
|
|
|
Optional. CSS class applied to the region’s |
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
Example
<RegionView
name="main"
components={layout.regions?.main?.components}
common={common}
meta={meta}
/>
RichTextView
Renders processed Guillotine rich text through @enonic/react-components. It adapts internal links, images, and macros to Next.XP URL processing and editing behavior.
Parameters
RichTextView() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Processed HTML plus referenced links, images, and macros returned by the adapter’s rich-text query. |
|
|
|
Runtime request and editing context used for URLs and annotations. |
|
|
|
|
Optional. CSS class applied to the rich-text wrapper. |
|
|
|
Optional. HTML element used as the wrapper. |
|
|
|
Optional. Render mapped macros in edit mode. Default: |
|
|
|
Optional. Replaces an HTML parser node. Returning the original node leaves it unchanged. |
Returns
JSX.Element.
Example
<RichTextView
data={part.config.body}
meta={meta}
className="article-body"
/>
See Rich text for the query and URL-processing requirements.
Fragment
Renders the component tree stored by an XP fragment. A full-page fragment reads the fragment region from page; an embedded fragment reads component.fragment.components.
Parameters
Fragment() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Optional. Fragment page used when rendering the fragment as complete content. |
|
|
|
Optional. Embedded fragment component. |
|
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
Returns
JSX.Element.
SingleComponent
Renders meta.requestedComponent for an incremental Content Studio component refresh. It returns no visible output when the requested component is absent.
Parameters
SingleComponent() takes a single props object with the FetchContentResult properties. It consumes meta and common.
Returns
JSX.Element.
StaticContent
Preserves server-rendered HTML during hydration. When the existing element contains HTML and condition is true, the client keeps that HTML instead of rendering children again.
Parameters
StaticContent() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
|
Enable preservation of existing server-rendered HTML. The runtime default is |
|
|
|
Optional. Content rendered on the server, during SPA navigation, or when |
|
|
|
Optional. Wrapper element name. Default: |
|
additional properties |
|
Optional. HTML properties forwarded to the wrapper element. |
Returns
ReactNode.
Example
<StaticContent condition={meta.renderMode === RENDER_MODE.EDIT}>
{children}
</StaticContent>
PropsView
Development view that prints JSON representations of known mapping props. Its declaration accepts any props object; these are the properties it displays:
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Optional. Page props to display. |
|
|
|
Optional. Part props to display. |
|
|
|
Optional. Layout props to display. |
|
|
|
Optional. Processed mapping data to display. |
|
|
|
Optional. Shared data to display. |
Returns
JSX.Element.
Text
Base mapping for XP text components. It delegates the text value to RichTextView and disables mapped macro rendering in edit mode.
Parameters
Text() takes a single props object with these properties:
| Name | Type | Description |
|---|---|---|
|
|
Text component containing a |
|
|
|
Runtime request and editing context. |
|
|
|
|
Path of the text component in the XP page tree. |
Returns
JSX.Element.
DefaultMacro
Fallback macro renderer from views/macros/DefaultMacro. It parses and renders config.body as HTML.
Parameters
DefaultMacro() takes a single props object with the MacroProps properties.
Returns
ReactElement.
DisableMacro
Renderer from views/macros/DisableMacro for disabled macros. It returns config.body without parsing the body as HTML.
Parameters
DisableMacro() takes a single props object with the MacroProps properties.
Returns
any, matching the type of config.body in the adapter declaration.
MissingComponent
Named export from views/BaseComponent that renders a visible diagnostic for an unregistered component.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Optional. Missing XP descriptor. |
|
|
|
Component kind. |
Returns
JSX.Element.
ErrorComponent
Named export from views/BaseComponent that renders a visible component error.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Optional. Component kind. |
|
|
|
Optional. XP descriptor. |
|
|
|
Error message. |
Returns
JSX.Element.
PlaceholderComponent
Named export from views/BaseComponent that renders a diagnostic when an initialized component produces empty output.
Parameters
| Name | Type | Description |
|---|---|---|
|
|
|
Optional. Component kind. |
|
|
|
Optional. XP descriptor. |
Returns
JSX.Element.
Classes
The view entry points export no classes.
Type Definitions
PageComponent
One normalized component in the XP page tree. The property matching type contains the kind-specific data.
| Name | Type | Description |
|---|---|---|
|
|
|
Component kind: |
|
|
|
Component path within the page tree. |
|
|
Optional. Present for a page component. |
|
|
|
Optional. Present for a layout component. |
|
|
|
Optional. Present for a part component. |
|
|
|
Optional. Present for a text component. |
|
|
|
Optional. Present for a fragment component. |
|
|
|
|
Optional. Present for an image component. |
|
|
Optional. Regions attached to the component. |
|
|
|
|
Optional. Processed result of the component mapping’s query. |
|
|
|
Optional. Component query or processing error. |
|
additional properties |
|
Optional. Fields selected by custom component queries. |
PageData
| Name | Type | Description |
|---|---|---|
|
|
|
Application-qualified XP page descriptor. |
|
|
|
Optional. Page configuration. |
|
|
|
Optional. Page-template reference. |
|
|
Optional. Regions owned by the page. |
LayoutData
| Name | Type | Description |
|---|---|---|
|
|
|
Application-qualified XP layout descriptor. |
|
|
|
Optional. Layout configuration. |
|
|
Optional. Normalized regions added before a mapped layout view is called. |
|
|
additional properties |
|
Optional. Fields selected by custom layout queries. |
PartData
| Name | Type | Description |
|---|---|---|
|
|
|
Application-qualified XP part descriptor. |
|
|
|
Part configuration. |
|
additional properties |
|
Optional. Fields selected by custom part queries. |
FragmentData
| Name | Type | Description |
|---|---|---|
|
|
|
Fragment content ID. |
|
|
|
Normalized components stored by the fragment. |
TextData
| Name | Type | Description |
|---|---|---|
|
|
Processed rich-text value. |
RichTextData
Rich-text result provided by @enonic/react-components and re-exported by the adapter.
| Name | Type | Description |
|---|---|---|
|
|
|
HTML containing reference markers for links, images, and macros. |
|
|
|
Optional. Resolved internal content and media links. |
|
|
|
Optional. Resolved images and image styles. |
|
|
MacroData`[]` |
Optional. Resolved macro descriptors and configurations. |
|
additional properties |
|
Optional. Additional fields carried by an extended rich-text query. |
MacroData
| Name | Type | Description |
|---|---|---|
|
|
|
Reference matching the macro marker in |
|
|
|
Macro name. |
|
|
|
Application-qualified macro descriptor. |
|
|
|
Macro configuration grouped by sanitized macro name. |
RegionTree
A record keyed by region name. Each value contains that region’s name and ordered components: PageComponent[].
FetchContentResult
Shared input to MainView, BaseContent, and SingleComponent. It is returned by fetchContent().
| Name | Type | Description |
|---|---|---|
|
|
|
Processed content-type query result. |
|
|
|
Processed shared-query result. |
|
|
Runtime request and editing context. |
|
|
|
PageComponent or |
Normalized page component tree. |
|
|
|
Optional. Structured fetch failure inherited from |
PageProps
Props passed by BasePage to a registered page view.
| Name | Type | Description |
|---|---|---|
|
|
Normalized page descriptor, configuration, template, and regions. |
|
|
|
|
Page component path. |
|
|
|
Optional. Processed result of the page mapping’s query. |
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
LayoutProps
Props passed by BaseLayout to a registered layout view.
| Name | Type | Description |
|---|---|---|
|
|
Normalized layout descriptor, configuration, and regions. |
|
|
|
|
Layout component path. |
|
|
|
Processed result of the shared query. |
|
|
Runtime request and editing context. |
PartProps
Props passed by BasePart to a registered part view.
| Name | Type | Description |
|---|---|---|
|
|
Normalized part descriptor, configuration, and queried fields. |
|
|
|
|
Part component path. |
|
|
|
Optional. Processed result of the part mapping’s query. |
|
|
|
Optional. Processed result of the shared query. |
|
|
Runtime request and editing context. |
MacroProps
Props passed by BaseMacro to a registered macro view. DefaultMacro and DisableMacro use the same shape.
| Name | Type | Description |
|---|---|---|
|
|
|
Macro name from the rich text. |
|
|
|
Content enclosed by the macro. |
|
|
|
Normalized macro configuration. |
|
|
Runtime request and editing context. |
Constants
MACRO_DISABLE
system:disable — descriptor used for XP’s disabled macro.
MACRO_EMBED
system:embed — descriptor used for XP’s embedded HTML macro.