Examples
The examples are organized by the decision a new app needs to make: how much framework structure do you want today?
Minimal example
apps/example-minimal shows Contract Kit at its smallest useful size.
It demonstrates:
- One contract group
- Two Next.js route handlers
- A Contract Kit server with no ports or providers
- Direct client
call()andsafeCall()usage
Run it from the monorepo root:
cd apps/example-minimal
bun run dev
Use this when you want to understand the contract, server, and client loop without application architecture.
Standard Next.js example
apps/example-next is the copyable reference app for most projects.
It demonstrates:
- Contract definitions
- Next.js route handlers
- Validated application use cases
- Ports and providers
- Structured errors
- React Query
- React Hook Form
- Direct
call()andsafeCall()usage - OpenAPI generation
cd apps/example-next
bun run dev
Use this when you want a normal full-stack app shape that stays small.
Application architecture example
apps/example-application shows how Contract Kit fits around business workflows.
It demonstrates:
- Application-layer commands and queries
- Domain entities and value objects
- Error catalogs
- Domain events published through an event bus port
- Ports and adapters
- Use-case tests that run without HTTP
- Contract-backed HTTP routes
cd apps/example-application
bun run dev
Use this when business behavior needs to be reusable from HTTP routes, jobs, scripts, event handlers, and tests.
Which example should I follow?
| Goal | Start with |
|---|---|
| Understand the core contract/server/client loop | apps/example-minimal |
| Build a normal full-stack Next.js app | apps/example-next |
| Model business workflows behind transport boundaries | apps/example-application |
| Add third-party providers such as auth, mail, jobs, or rate limiting | CLI integration presets |