Examples
Learn Effect Schema through practical, real-world examples. Each example demonstrates common patterns and best practices you'll encounter in production applications.
What You'll Learn
These examples cover a range of use cases from simple API validation to complex domain modeling:
API Validation
Build type-safe REST APIs with request/response validation, pagination, and error handling.
Form Validation
Integrate Schema with React Hook Form for client-side validation with custom error messages.
Configuration
Parse environment variables and configuration files with automatic type coercion.
Domain Modeling
Model complex business domains with branded types, state machines, and discriminated unions.
Database Integration
Transform between database representations and application types with Prisma.
WebSocket Messages
Create type-safe bidirectional communication protocols for real-time applications.
Prerequisites
These examples assume you have:
- Basic familiarity with TypeScript
- Read the Quick Start guide
- Understanding of Core Concepts
Running the Examples
All examples can be run in a TypeScript project with Effect installed:
npm install effectThen create a .ts file and copy the example code. Most examples are self-contained and can be run directly with ts-node or tsx:
npx tsx example.tsMore Resources
- Effect Examples Repository - Official examples
- Discord Community - Ask questions and share examples
- Best Practices - Schema design patterns