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:app
sections
my-component
index.tsx
schema.ts
loader.ts
index.tsx: main component fileschema.ts: schema definition (optional separate file)loader.ts: data loader (optional separate file)
Required Exports
Each component file must export:- Default export - The React component
- schema export - Component configuration
- 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
- Import your component in the components file:
- 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 creationchildTypes, so Studio treats it as child-only. If so, keep the existing type and add enabledOn: { groups: ['*'] } (or ['body']). Other availability rules, such as enabled, enabledOn.pages, and limit, can also hide a component, so check them too. See Standalone and Nested Components.
Problem: Import path errors
* 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’sname fields:
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
- Learn about Input Settings
- Master Component Schemas
- Explore Data Fetching
- Review Styling & Theming