Skip to content

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:

Running the Examples

All examples can be run in a TypeScript project with Effect installed:

bash
npm install effect

Then create a .ts file and copy the example code. Most examples are self-contained and can be run directly with ts-node or tsx:

bash
npx tsx example.ts

More Resources

Released under the MIT License.