Overview
The Contract Kit client provides a fully typed HTTP client with endpoints derived from your contracts. No code generation required - just pure TypeScript inference.Creating a Client
Basic Setup
With Options
Making Requests
GET Requests
With Query Parameters
POST Requests
With Authentication
Response Handling
Success Responses
The client returns the validated success payload (200/201/204) and throws on non-2xx responses:Error Handling
Client Configuration
Global Headers
Per-Request Headers
Custom Fetch
React Integration
With React Query
With SWR
Advanced Usage
Retry Logic
Request Interceptors
Type Safety
The client provides complete type safety:Best Practices
Create a single client instance
Create a single client instance
Export one client instance and reuse it throughout your app to avoid duplication.
Handle all status codes
Handle all status codes
Always check the status code and handle both success and error cases.
Use environment variables for URLs
Use environment variables for URLs
Configure the base URL using environment variables for different environments.
Add authentication globally
Add authentication globally
Use global fetch options or interceptors to add authentication headers automatically.
Implement proper error handling
Implement proper error handling
Catch network errors and handle them gracefully in your UI.