Overview
This section contains detailed API documentation for all Contract Kit packages. Each package has comprehensive documentation of its exports, types, and usage patterns.Core API
contract-kit (meta package)
- createContractGroup(), createClient(), createUseCaseFactory(), definePorts()
- Re-exports core, client, application, domain, ports, errors, config, and OpenAPI helpers
@contract-kit/core
- createContractGroup() - Create a group of related contracts
- Contract builders -
.get(),.post(),.put(),.patch(),.delete() - Schema methods -
.path(),.query(),.body(),.response(),.errors() - Metadata methods -
.meta(), plus OpenAPI helpers like.summary()and.tags()
@contract-kit/server
- createServer() - Create a framework-agnostic server
- Middleware - Request pipeline and middleware support
- Context - Request-scoped context creation
- Error handling - Global and route-level error handlers
@contract-kit/client
- createClient() - Create a typed HTTP client
- Request methods - Type-safe API calls
- Response handling - Typed response handling
- Configuration - Global and per-request options
Server Adapters
@contract-kit/next
- createNextServer() - Next.js server initialization
- Route handlers - App Router and Pages Router support
- Configuration - Next.js adapter options
Architecture APIs
@contract-kit/application
- createUseCaseFactory() - Create a typed use case factory
- useCase.command() / useCase.query() - Define use cases
- run() - Execute a use case
- Validation - Input/output validation
@contract-kit/ports
- definePorts() - Define application ports
- Provider registration - Register provider implementations
- Type safety - Fully typed dependency injection
React APIs
@contract-kit/react-query
- createRQ() - Create the React Query adapter
- rq(contract).queryOptions() - Typed query options
- rq(contract).mutationOptions() - Typed mutation options
- Configuration - Query client setup
@contract-kit/react-hook-form
- rhf(contract) - Create a React Hook Form adapter
- useForm() - Form hook with validation
- Schema integration - Standard Schema resolver generation
Provider APIs
Each provider package exports:- create[Provider]Provider() - Factory function
- Configuration options - Provider-specific config
- Port interface - TypeScript interface for the port
- @contract-kit/provider-redis
- @contract-kit/provider-drizzle-turso
- @contract-kit/provider-mail-resend
- @contract-kit/provider-mail-smtp
- @contract-kit/provider-auth-better-auth
- @contract-kit/provider-inngest
- @contract-kit/provider-rate-limit-upstash
Utility APIs
@contract-kit/openapi
- contractsToOpenAPI() - Generate OpenAPI 3.1 spec
- Configuration - OpenAPI generation options
- Customization - Extend generated spec