M0rphicZone

Renders an adaptive UI zone that can display different components based on AI decisions, A/B tests, or static configuration.

Basic Usage

typescript

Props

PropTypeDefaultDescription
zoneId*string-Unique identifier for this zone within the page.
pageIdstring"default"Identifier for the page containing this zone.
components*Record<string, ComponentType>-Map of component names to React components.
defaultLayout*string[]-Array of component names to render by default.
strategy"ai" | "ab-test" | "static""ai"How the zone determines which components to render.
experimentIdstring-Explicit experiment ID for ab-test strategy.
classNamestring-Custom className for the zone container.
fallbackReact.ReactNode-Content to show while loading the layout.
onLayoutLoaded(layout: LayoutConfig | null) => void-Callback when the layout is loaded from server.

Zone Strategies

AI Strategy

The AI strategy uses m0rphic's AI to automatically select the best components based on user behavior and context:

typescript

Note

AI decisions are made server-side based on user profiles, behavior patterns, and experiment results. The default layout is shown until a decision is available.

A/B Test Strategy

Run explicit A/B tests by specifying an experiment:

typescript

Static Strategy

Always render the default layout without any personalization:

typescript

Multiple Components

A zone can render multiple components in sequence:

typescript

Loading States

Customize the loading experience with the fallback prop:

typescript

Tip

For critical above-the-fold content, consider using strategy="static" to avoid any loading delay.

Automatic Event Tracking

M0rphicZone automatically tracks events for components rendered within it:

  • •view - When a component becomes visible
  • •click - When a component is clicked
  • •hover - Significant hover interactions

For more granular tracking, use the useTrackComponent hook.