Backend API
API Integration
How to integrate with the Hireable API from frontend applications
Overview
This guide covers how to integrate with the Hireable API from the frontend application using the provided services and hooks.
API Client Setup
The API client is configured in @/services/api:
Making Requests
Authentication
Set the auth token after login:
The token is automatically included in the Authorization header:
Using Services
Services encapsulate API calls for specific features:
Auth Service
Waitlist Service
Using Hooks
useApi Hook
For generic API calls with state management:
useAuth Hook
For authentication state:
Error Handling
API Client Errors
With useApi Hook
Type Safety
Import types from @hireable/shared:
Environment Configuration
Configure API settings in .env.local:
Best Practices
- Use services for API calls - Don't call
apiClientdirectly in components - Use hooks for state management -
useApihandles loading, error, and caching - Import types from shared - Ensures type consistency across the stack
- Handle errors appropriately - Show user-friendly messages, log details
- Use caching wisely - Cache stable data, invalidate on mutations