> ## Documentation Index
> Fetch the complete documentation index at: https://weaverse.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Weaverse component configuration uses `settings`. `inspector` is deprecated; never generate it.
> Weaverse Hydrogen themes use React Router v7: import from `react-router`, never `react-router-dom` or `@remix-run/*`.
> Before using any code sample, read `@weaverse/hydrogen` in the project's `package.json`: 6.x and 5.x import from different entries and use different type names, so code for one does not build on the other.
> `@weaverse/hydrogen` 6 (Shopify Hydrogen 2026.10 and later, the version these docs show) imports from `@weaverse/hydrogen/react-router` and uses `Weaverse*` types such as `WeaverseComponentProps`, `WeaverseComponentLoaderArgs` and `WeaverseComponentSchema`; the root `@weaverse/hydrogen` entry only exports `createSchema()`, data helpers and types.
> `@weaverse/hydrogen` 5.x (Hydrogen 2026.4 and earlier) imports everything from `@weaverse/hydrogen` and uses `HydrogenComponentProps`, `ComponentLoaderArgs` and `HydrogenComponentSchema`. On a 5.x project, convert samples to these names. Upgrade to 6 only when asked (`npx @weaverse/cli@latest migrate v6`, plus the Hydrogen 2026.10 upgrade). Do not mix major versions.
> Next.js themes use `@weaverse/hydrogen` 6.2.0 or later: import client and shared code from `@weaverse/hydrogen/next` and server-only code from `@weaverse/hydrogen/next/server`. `@weaverse/next` is deprecated; never install or import it.
> For live project data (pages, theme settings, translations), use the Weaverse MCP server: https://weaverse.io/docs/developer-tools/weaverse-mcp

# Component Schema

> Define how a Next.js section appears in Weaverse Studio, which settings it exposes and where it can be used, with createSchema from @weaverse/hydrogen/next.

# Component Schema

> **Agent note:** Generate `settings` for every new schema, never `inspector`. In Next.js themes, import `createSchema` from `@weaverse/hydrogen/next` and keep each schema in its own server-safe module (no `'use client'`, no client-only imports), because both the client and the server registries import it. When migrating an `inspector` schema, move each group to `settings` and delete the original: if both arrays exist, the SDK concatenates them and Studio shows the groups twice.

A component's schema links your code to Weaverse Studio. It sets the name merchants see, the settings they can edit, which components can be nested inside it, and on which pages it can be added.

## Where the Schema Lives

In a Next.js storefront, put each schema in its own module and re-export it from the component:

```ts theme={null}
// sections/related-products/schema.ts
import { createSchema } from '@weaverse/hydrogen/next'
import { layoutInputs } from '@/components/section/inputs'

export let schema = createSchema({
  type: 'related-products',
  title: 'Related products',
  limit: 1,
  enabled: ({ page }) => page.type === 'PRODUCT',
  settings: [{ group: 'Layout', inputs: layoutInputs }],
})
```

```tsx theme={null}
// sections/related-products/index.tsx
'use client'

function RelatedProducts(props: RelatedProductsProps) {
  // ...
}

export default RelatedProducts

export { schema } from './schema'
```

Both registries need the schema. The client registry imports the component module (and gets the schema through the re-export); the server registry imports `schema.ts` directly, next to the loader. So the schema module must stay server-safe: no `'use client'`, no hooks, no imports of client components. Type-only imports are fine. See [Creating Components](https://weaverse.io/docs/nextjs/creating-components.md#3-register-the-component).

## The createSchema() Function

`createSchema()` takes a schema object and returns it unchanged:

* **Type checking.** It accepts the public `SchemaType`, so TypeScript checks your schema and autocompletes its properties.
* **Development diagnostics.** Outside production, it validates the schema asynchronously and logs issues as warnings. Warnings never throw or stop a build.
* **No production cost.** Production builds skip the validation code.

```ts theme={null}
import { createSchema } from '@weaverse/hydrogen/next'

export let schema = createSchema({
  type: 'my-component',
  title: 'My component',
  settings: [],
})
```

You can also annotate the object with `SchemaType` instead. It is the same contract without the development diagnostics:

```ts theme={null}
import type { SchemaType } from '@weaverse/hydrogen/next'

export let schema: SchemaType = {
  type: 'my-component',
  title: 'My component',
  settings: [],
}
```

## Anatomy

```ts theme={null}
createSchema({
  title: string
  type: string
  label?: (data: Record<string, any>) => string | null | undefined
  settings?: InspectorGroup[]
  childTypes?: string[]
  presets?: Omit<ComponentPresets, 'type'>
  limit?: number
  enabled?: boolean | ((context: ComponentAvailabilityContext) => boolean)
  /** @deprecated Use `enabled` instead */
  enabledOn?: {
    pages?: ('*' | PageType)[]
    groups?: ('*' | 'header' | 'footer' | 'body')[]
  }
  /** @deprecated Use `settings` instead */
  inspector?: InspectorGroup[]
})
```

## Essential Properties

### `title` and `type`

`title` is the name merchants see in the Page Outline and the Add Section menu. Keep it short (one to three words), in plain language.

![Page outline](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/tittle-and-type.webp?v=1743409496)

`type` is the component's unique identifier. Weaverse stores it on every saved instance and uses it to find the component in your registries, so:

* use kebab-case (`hero-banner`, `featured-products`),
* keep it unique across the theme, and
* don't rename it once merchants have used the component: saved instances keep the old type and no longer match.

The client and server registries pair a schema with its component and loader by `type`, so a loader keyed under a different string never runs.

### `label`

The optional `label` callback helps merchants tell repeated elements apart in the Page Outline. Studio keeps the `title` and appends the returned text as a muted suffix: **Heading – Summer sale**. The Add Section menu still shows `title` alone.

This is Forward's `heading` schema, trimmed. It annotates `data` with the component's props type, imported as a type only:

```ts theme={null}
// components/heading/schema.ts
import { createSchema } from '@weaverse/hydrogen/next'
import type { HeadingProps } from '.'

export let schema = createSchema({
  type: 'heading',
  title: 'Heading',
  label: (data: HeadingProps) => data.content,
  settings: [
    {
      group: 'Heading',
      inputs: [{ type: 'text', name: 'content', label: 'Text' }],
    },
  ],
  presets: { content: 'Section heading' },
})
```

* **Per instance.** One callback applies to every instance, each with its own current data.
* **Preview language.** Data includes current edits and the translations for the preview's content language, and labels update as either changes.
* **Plain text, synchronously.** Return a string, `null` or `undefined`. Don't return JSX, HTML or a Promise, and don't cause side effects. Blank results, thrown errors and async results show the title alone.
* **Display only.** The label is computed in the storefront preview and never saved to your content.

### `settings`

`settings` lists the controls merchants get in the Studio settings panel, as groups of inputs:

```ts theme={null}
interface InspectorGroup {
  group: string
  inputs: (BasicInput | HeadingInput)[]
}
```

* `group` is the group's label, such as "Content", "Layout" or "Style".
* `inputs` are the controls. Each input's `name` is the prop your component receives.

```ts theme={null}
export let schema = createSchema({
  type: 'featured-collection',
  title: 'Featured collection',
  settings: [
    {
      group: 'Content',
      inputs: [
        {
          type: 'text',
          name: 'heading',
          label: 'Heading',
          defaultValue: 'Featured products',
        },
        {
          type: 'collection',
          name: 'collection',
          label: 'Collection',
          shouldRevalidate: true,
        },
      ],
    },
    {
      group: 'Style',
      inputs: [
        {
          type: 'toggle-group',
          name: 'alignment',
          label: 'Text alignment',
          defaultValue: 'center',
          configs: {
            options: [
              { value: 'left', label: 'Left' },
              { value: 'center', label: 'Center' },
              { value: 'right', label: 'Right' },
            ],
          },
        },
      ],
    },
  ],
})
```

Each input's `defaultValue` seeds a new instance, and the SDK merges the defaults under saved settings before your component and its loader see them. Keep group names and their order consistent across components so merchants learn them once.

[Input Settings](https://weaverse.io/docs/nextjs/input-settings.md) lists every input type and what it returns.

## Component Relationships

### `childTypes`

`childTypes` lists the component types merchants can add inside this one. Without it, the component accepts no children. Render the children through the `children` prop:

```ts theme={null}
export let schema = createSchema({
  type: 'featured-products',
  title: 'Featured products',
  childTypes: ['section-content'],
  settings: [],
})
```

Every type you list must be registered.

### Standalone and Nested Components

Listing a type in any registered component's `childTypes` makes Studio treat that type as child-only: it disappears from the root **Add Section** picker, even when `enabled` returns `true`.

To use a component both as a section and nested inside a parent, keep the parent's `childTypes` and the child's `type`, and add `enabledOn.groups` with `'*'` or `'body'` to the child:

```ts sections/feature-list/schema.ts theme={null}
import { createSchema } from '@weaverse/hydrogen/next'

// Parent: still allows the child in its nested picker
export let schema = createSchema({
  type: 'feature-list',
  title: 'Feature list',
  childTypes: ['feature-card'],
  settings: [],
})
```

```ts sections/feature-card/schema.ts theme={null}
import { createSchema } from '@weaverse/hydrogen/next'

// Child: also available as a root section
export let schema = createSchema({
  type: 'feature-card', // keep the existing type so saved instances still match
  title: 'Feature card',
  enabledOn: { groups: ['*'] }, // opts back into the root picker
  enabled: ({ page }) => page.type !== 'PRODUCT', // other rules still apply
  settings: [],
})
```

* Studio evaluates body placement only today, so `['*']` and `['body']` both make the component eligible for **Add Section**. Use `['*']` when the component had no `groups` before, so the opt-in adds no restriction.
* Every other rule must still pass, including `enabled` and `enabledOn.pages`.
* The nested picker is unaffected.

Keep this `enabledOn` field on dual-use components even after moving other availability rules to `enabled`.

### `presets`

`presets` sets the settings and children a component starts with when a merchant adds it:

```ts theme={null}
type ComponentPresets = {
  type: string
  children?: ComponentPresets[]
  [key: string]: any // values keyed by input name
}
```

This is Forward's `featured-products` preset. It adds two `section-content` children, each with its own nested elements, so a new section is ready to use:

```ts theme={null}
export let schema = createSchema({
  type: 'featured-products',
  title: 'Featured products',
  childTypes: ['section-content'],
  settings: [/* ... */],
  presets: {
    children: [
      {
        type: 'section-content',
        children: [
          { type: 'subheading', content: 'New field rotation' },
          { type: 'heading', content: 'Start with the core four.' },
        ],
      },
      {
        type: 'section-content',
        justify: 'end',
        children: [
          { type: 'button', label: 'Shop the full catalog', href: '/shop' },
        ],
      },
    ],
  },
})
```

> [!NOTE]
>
> Don't hardcode product or collection handles in presets: they differ from store to store. Leave resource pickers empty and render a placeholder until the merchant picks one, as Forward's `featured-products` does.

## Availability and Placement

### `limit`

`limit` caps how many instances can exist in the parent (or on the page, for top-level sections). When the limit is reached, Studio disables the component in the Add menu.

```ts theme={null}
export let schema = createSchema({
  type: 'announcement-bar',
  title: 'Announcement bar',
  limit: 1,
  settings: [],
})
```

### `enabled`

```ts theme={null}
enabled?: boolean | ((context: ComponentAvailabilityContext) => boolean)
```

`enabled` controls whether the component can be inserted on the current page. Use a boolean for a simple switch, or a synchronous callback that inspects the page:

```ts theme={null}
export let schema = createSchema({
  type: 'freebie-banner',
  title: 'Freebie banner',
  enabled: ({ page, group }) =>
    group === 'body' &&
    page.type === 'CUSTOM' &&
    page.handle === 'freebies/essential',
  settings: [],
})
```

The callback receives:

```ts theme={null}
interface ComponentAvailabilityContext {
  page: {
    id: string
    type: PageType
    handle: string
    locale: string
  }
  group: 'body' | 'header' | 'footer'
}

type PageType =
  | 'INDEX'
  | 'PRODUCT'
  | 'ALL_PRODUCTS'
  | 'COLLECTION'
  | 'COLLECTION_LIST'
  | 'PAGE'
  | 'BLOG'
  | 'ARTICLE'
  | 'CUSTOM'
```

The callback runs in the storefront preview, from the client registry, whenever Studio sets up or refreshes its page context. `page.type` and `page.handle` come from the route identity your route reports; see [Report the route identity](https://weaverse.io/docs/nextjs/studio.md#report-the-route-identity).

The callback must be pure and return a boolean right away. Returning anything else, returning a Promise or throwing makes the component unavailable for new insertion without breaking Studio. Existing instances stay visible and editable.

> [!NOTE]
>
> Studio evaluates insertion for the `body` group today. `header` and `footer` are reserved for future placement surfaces.

### `enabledOn` (deprecated)

```ts theme={null}
enabledOn?: {
  pages?: ('*' | PageType)[]
  groups?: ('*' | 'header' | 'footer' | 'body')[]
}
```

`enabledOn` is the older way to restrict availability. It still works, and when a schema has both, both rules must pass. For new rules, use `enabled`:

```ts theme={null}
// Before
export let schema = createSchema({
  type: 'product-recommendations',
  title: 'Product recommendations',
  enabledOn: { pages: ['PRODUCT'], groups: ['body'] },
})

// After
export let schema = createSchema({
  type: 'product-recommendations',
  title: 'Product recommendations',
  enabled: ({ page, group }) => page.type === 'PRODUCT' && group === 'body',
})
```

> [!WARNING]
>
> Keep `enabledOn.groups` on a component that is listed in another component's `childTypes` and must still appear as a section. `enabled` does not replace that opt-in. See [Standalone and Nested Components](#standalone-and-nested-components).

> [!NOTE]
>
> Until [Weaverse/builder#3454](https://github.com/Weaverse/builder/issues/3454) ships, Studio's **Page sections** grouping in the Add Section menu still reads `enabledOn.pages`, so a page-specific section that uses only `enabled` is listed with the general sections. Availability is the same either way.

## Conditional Inputs

An input's `condition` shows it only when the condition matches. Use a function, which receives the component's current data. `condition` isn't typed per component, so annotate `data` yourself (strict TypeScript otherwise reports an implicit `any`):

```ts theme={null}
interface BannerData {
  showButton?: boolean
}

{
  type: 'switch',
  name: 'showButton',
  label: 'Show button',
  defaultValue: true,
},
{
  type: 'text',
  name: 'buttonText',
  label: 'Button text',
  condition: (data: BannerData) => data.showButton === true,
}
```

Conditions can combine several fields:

```ts theme={null}
{
  type: 'range',
  name: 'maxItems',
  label: 'Maximum items',
  defaultValue: 10,
  configs: { min: 1, max: 20, step: 1 },
  condition: (data: { layout?: string; showAll?: boolean }) =>
    data.layout === 'grid' && data.showAll !== true,
}
```

The string form (`condition: 'showButton.eq.true'`) is deprecated. Use functions for new components.

## Re-running Loaders

`shouldRevalidate: true` on an input re-runs the component's loader when a merchant changes that input in Studio. Set it on every input your loader reads, resource pickers included:

```ts theme={null}
{
  type: 'product-list',
  name: 'products',
  label: 'Products',
  shouldRevalidate: true,
}
```

In a Next.js storefront, loaders live only in the server registry, so Studio can't see that a component has one. Without the flag, changing the input updates the settings but keeps the old `loaderData`. The re-run goes through your revalidation route; see [Per-item revalidation](https://weaverse.io/docs/nextjs/studio.md#per-item-revalidation).

## Heading Inputs

A `heading` input adds a title inside a settings group. It holds no data:

```ts theme={null}
{ type: 'heading', label: 'Typography' }
```

## Sharing Inputs Between Schemas

Inputs are plain data, so you can define common ones once and reuse them. Forward declares its layout inputs in one module and spreads them into every section:

```ts theme={null}
// components/section/inputs.ts
import type { InspectorGroup } from '@weaverse/hydrogen/next'

type SectionInputs = InspectorGroup['inputs']

export let layoutInputs: SectionInputs = [
  {
    type: 'select',
    name: 'width',
    label: 'Content width',
    configs: {
      options: [
        { value: 'full', label: 'Full page' },
        { value: 'stretch', label: 'Stretch' },
        { value: 'fixed', label: 'Fixed' },
      ],
    },
  },
  {
    type: 'range',
    name: 'gap',
    label: 'Items spacing',
    configs: { min: 0, max: 60, step: 4, unit: 'px' },
  },
]
```

```ts theme={null}
// sections/featured-products/schema.ts
import { createSchema } from '@weaverse/hydrogen/next'
import { layoutInputs } from '@/components/section/inputs'

export let schema = createSchema({
  type: 'featured-products',
  title: 'Featured products',
  settings: [
    { group: 'Layout', inputs: layoutInputs },
    // ...
  ],
})
```

Keep shared input modules server-safe too, since schemas import them.

## Complete Example

```ts theme={null}
// sections/product-showcase/schema.ts
import { createSchema } from '@weaverse/hydrogen/next'

interface ShowcaseData {
  showViewAll?: boolean
  layout?: 'grid' | 'carousel'
}

export let schema = createSchema({
  type: 'product-showcase',
  title: 'Product showcase',
  limit: 3,
  enabled: ({ page }) => ['INDEX', 'COLLECTION', 'PRODUCT'].includes(page.type),
  childTypes: ['heading', 'paragraph'],
  settings: [
    {
      group: 'Content',
      inputs: [
        {
          type: 'switch',
          name: 'showViewAll',
          label: 'Show "View all" link',
          defaultValue: true,
        },
        {
          type: 'text',
          name: 'viewAllText',
          label: 'Link text',
          defaultValue: 'View all products',
          condition: (data: ShowcaseData) => data.showViewAll === true,
        },
      ],
    },
    {
      group: 'Products',
      inputs: [
        {
          type: 'collection',
          name: 'collection',
          label: 'Collection',
          helpText: 'Products are pulled from this collection.',
          shouldRevalidate: true,
        },
        {
          type: 'range',
          name: 'productCount',
          label: 'Number of products',
          defaultValue: 4,
          configs: { min: 2, max: 12, step: 1 },
          shouldRevalidate: true,
        },
      ],
    },
    {
      group: 'Style',
      inputs: [
        {
          type: 'select',
          name: 'layout',
          label: 'Layout',
          defaultValue: 'grid',
          configs: {
            options: [
              { value: 'grid', label: 'Grid' },
              { value: 'carousel', label: 'Carousel' },
            ],
          },
        },
        {
          type: 'range',
          name: 'productsPerRow',
          label: 'Products per row',
          defaultValue: 4,
          configs: { min: 2, max: 5, step: 1 },
          condition: (data: ShowcaseData) => data.layout === 'grid',
        },
        {
          type: 'color',
          name: 'backgroundColor',
          label: 'Background color',
        },
      ],
    },
  ],
  presets: {
    children: [
      { type: 'heading', content: 'Featured products' },
      { type: 'paragraph', content: 'Our most popular pieces this season.' },
    ],
  },
})
```

## Migrating from `inspector`

`inspector` is the old name for `settings`. Rename it:

```ts theme={null}
// Before (deprecated)
export let schema = createSchema({
  type: 'my-component',
  title: 'My component',
  inspector: [{ group: 'Content', inputs: [/* ... */] }],
})

// After
export let schema = createSchema({
  type: 'my-component',
  title: 'My component',
  settings: [{ group: 'Content', inputs: [/* ... */] }],
})
```

A schema with only `inspector` still works and logs a deprecation warning.

> [!WARNING]
>
> `settings` does not replace `inspector`. When a schema has both, the SDK concatenates them (`settings` first), so a group copied into `settings` without deleting it from `inspector` shows up twice in Studio. Delete each `inspector` group as you move it.

## Troubleshooting

* **Validation warnings in the console.** In development, `createSchema()` logs warnings for missing fields, unknown input types or malformed configs. Fix them; they don't stop the build.
* **Duplicate type.** Each `type` must be unique across the theme.
* **Child component not offered.** Its type isn't in the parent's `childTypes`, or it isn't in the client registry.
* **Component missing from Add Section.** Check `enabled` for the current page type, handle, locale and group, then `limit`. If its type is in another component's `childTypes`, see [Standalone and Nested Components](#standalone-and-nested-components).
* **Wrong page type in `enabled`.** The route reports a different `pageType` or `handle` than you expect. See [Report the route identity](https://weaverse.io/docs/nextjs/studio.md#report-the-route-identity).
* **Data doesn't refresh after an edit.** The input lacks `shouldRevalidate: true`. See [Re-running Loaders](#re-running-loaders).
* **A client component ends up in the server bundle.** The schema module imports the component (or another client module) at runtime. Use `import type`, or move shared values into a server-safe module.
* **Groups appear twice.** The schema has both `settings` and `inspector`. See [Migrating from `inspector`](#migrating-from-inspector).

## Next Steps

> [card] [Input Settings](https://weaverse.io/docs/nextjs/input-settings.md)
>
> Every input type and what it returns.

> [card] [Creating Components](https://weaverse.io/docs/nextjs/creating-components.md)
>
> Write, register and type a component.

> [card] [Data Fetching](https://weaverse.io/docs/nextjs/data-fetching.md)
>
> Loaders, caching and per-item revalidation.

> [card] [Studio Integration](https://weaverse.io/docs/nextjs/studio.md)
>
> Route identity, revalidation and theme routes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.