Component Schema
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: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.
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.
SchemaType instead. It is the same contract without the development diagnostics:
Anatomy
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.
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.
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:
- 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,
nullorundefined. 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:
groupis the group’s label, such as “Content”, “Layout” or “Style”.inputsare the controls. Each input’snameis the prop your component receives.
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 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:
Standalone and Nested Components
Listing a type in any registered component’schildTypes 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:
sections/feature-list/schema.ts
sections/feature-card/schema.ts
- Studio evaluates body placement only today, so
['*']and['body']both make the component eligible for Add Section. Use['*']when the component had nogroupsbefore, so the opt-in adds no restriction. - Every other rule must still pass, including
enabledandenabledOn.pages. - The nested picker is unaffected.
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:
featured-products preset. It adds two section-content children, each with its own nested elements, so a new section is ready to use:
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.
enabled
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:
page.type and page.handle come from the route identity your route reports; see 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.
Studio evaluates insertion for the
body group today. header and footer are reserved for future placement surfaces.enabledOn (deprecated)
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:
Until Weaverse/builder#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’scondition 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):
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:
loaderData. The re-run goes through your revalidation route; see Per-item revalidation.
Heading Inputs
Aheading input adds a title inside a settings group. It holds no data:
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:Complete Example
Migrating from inspector
inspector is the old name for settings. Rename it:
inspector still works and logs a deprecation warning.
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
typemust 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
enabledfor the current page type, handle, locale and group, thenlimit. If its type is in another component’schildTypes, see Standalone and Nested Components. - Wrong page type in
enabled. The route reports a differentpageTypeorhandlethan you expect. See Report the route identity. - Data doesn’t refresh after an edit. The input lacks
shouldRevalidate: true. See 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
settingsandinspector. See Migrating frominspector.
Next Steps
Input Settings
Every input type and what it returns.
Creating Components
Write, register and type a component.
Data Fetching
Loaders, caching and per-item revalidation.
Studio Integration
Route identity, revalidation and theme routes.