Welcome to Motia! This section contains beginner-friendly examples to help you learn core Motia concepts.
- Creating API endpoints (API Steps)
- Processing background events (Event Steps)
- Using middleware for authentication and validation
- Managing queues and job processing
- Building real-time applications with Server-Sent Events (SSE)
Concepts: Middleware, Authentication, Request/Response Processing
Learn how to create reusable middleware for authentication, validation, and error handling in your Motia applications.
Key Features:
- JWT authentication middleware
- Request validation
- Error handling patterns
- Middleware composition
Concepts: API Steps, Local LLM Integration
Build a simple chat interface using Ollama for local AI model inference.
Key Features:
- API endpoint creation
- Ollama integration
- Basic chat flow
- Local AI inference
Concepts: Queues, Event Steps, Background Processing
Understand how to manage job queues and process tasks asynchronously.
Key Features:
- Queue management
- Job processing
- Event-driven architecture
- Retry mechanisms
Concepts: Real-time Streaming, SSE, State Management
Create a real-time todo application with Server-Sent Events for instant updates.
Key Features:
- Server-Sent Events (SSE)
- Real-time updates
- State management
- CRUD operations
Concepts: Real-time Streaming, WebSocket, Collaborative Features
Build a real-time cursor sharing system with Motia Streams - perfect for collaborative apps.
Key Features:
- Real-time cursor position sync via WebSocket
- Room-based collaboration
- User colors and names
- Auto cleanup when users leave
- Next.js frontend demo
- Choose an example that matches what you want to learn
- Navigate to the example directory
- Follow the README in each example
- Run
npm install(orpip install -r requirements.txtfor Python) - Start the dev server with
npm run dev(orpython -m motia dev) - Open the Workbench at
http://localhost:3000
We recommend following this order:
- middleware-auth-handler-example - Understand middleware basics
- queue-example - Learn event-driven architecture
- ollama-chat - Build your first API endpoint
- realtime-todo-app - Add real-time capabilities
- real-time-cursor-pointers - Build collaborative real-time features
Once you're comfortable with these examples, move on to:
- Foundational Examples - Common patterns for real-world apps
- AI Agents - AI-powered applications