Skip to main content

Creating Components

This guide walks you through creating Weaverse components from scratch, covering everything from basic component structure to advanced patterns with TypeScript and React 19.

Component Structure

Every Weaverse component follows this structure:
Or as a single file:

Required Exports

Each component file must export:
  1. Default export - The React component
  2. schema export - Component configuration
  3. loader export (optional) - Server-side data loading

Basic Component Example

Here’s a simple component following modern React 19 patterns:

Component Registration

IMPORTANT: After creating your component, you must register it in the components file to make it available in Weaverse Studio.

Registration Steps

  1. Import your component in the components file:
  1. Restart your development server to see the component in Weaverse Studio:

Registration Example from Pilot Template

Here’s how components are registered in the official Pilot template:

Common Registration Issues

Problem: Component doesn’t appear in Weaverse Studio after creation
Solution: Always register new components in the components array
Problem: Import path errors
Solution: Always use namespace imports with * as

Schema Definition

The schema defines how your component appears and behaves in Weaverse Studio:

Basic Schema Structure

Input Types

Weaverse supports various input types:

TypeScript Integration

Component Props Interface

Always define proper TypeScript interfaces:

Schema Type Safety

Schemas are runtime configuration, not a source of TypeScript types — there is no type helper that infers props from a schema. Declare an interface for the values your inputs produce and keep it in sync with the schema’s name fields:
In development (NODE_ENV !== 'production'), createSchema() validates the schema and logs any issues it finds, so malformed settings surface early. The validation is skipped in production builds.

Data Loading

For components that need server-side data, export a loader function:

Styling Patterns

Tailwind CSS Integration

Use Tailwind classes for styling:

Class Variance Authority (CVA)

For complex component variants:

Best Practices

1. Component Organization

2. Error Boundaries

3. Loading States

4. Responsive Design

Advanced Patterns

Context Providers

Compound Components

Schema Composition

Next Steps

Component not selectable in Studio? If your component renders but can’t be clicked or edited, you’re likely not spreading props correctly or returning null. See the Component Not Selectable guide to fix it.
For more examples, check out the Example Components and join our Slack community for help.