connect-to-backend-api

Create TypeScript service files that connect Next.js frontend components to backend API endpoints.

Updated Oct 6, 2025
One-click install
npx skills add https://github.com/TheSmartHost-Co/thesmarthost --skill connect-to-backend-api-thesmarthost-co
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: connect-to-backend-api
Source: https://github.com/TheSmartHost-Co/thesmarthost/tree/main/.claude/skills/connect-to-backend-api
Command: npx skills add https://github.com/TheSmartHost-Co/thesmarthost --skill connect-to-backend-api-thesmarthost-co

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Connecting frontend components to backend APIs involves repetitive boilerplate: writing typed service functions, handling success/failed response statuses, catching network errors, and showing user notifications. This Skill standardizes that entire integration layer so every API call follows the same proven pattern. ## Core Features & Use Cases - Service File Generation: Produces complete CRUD service files (GET, POST, PUT, PATCH, DELETE) using the project's apiClient with full TypeScript typing and JSDoc comments. - Type Definition Templates: Creates matching type files with entity interfaces, create/update payloads, and response wrappers following the status/message/data convention. - Error Handling Patterns: Provides component-level patterns for client-side validation, backend error messages, network exceptions, loading states, and optimistic updates with rollback. - Use Case: You need to add a new 'bookings' feature. Use this Skill to generate bookingService.ts with all CRUD functions, the types/booking.ts file, and wire the create-booking modal with proper error notifications. ## Quick Start Create a service file for the bookings resource that connects to the backend API with full CRUD operations and error handling.

Frequently Asked Questions about connect-to-backend-api

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a service file to call a backend API in Next.js?▼

Create a [resource]Service.ts file in src/services that imports the shared apiClient and exports named async functions for each operation. Pair it with a types file defining the entity, payloads, and response wrappers, then call these functions from your components.

How to handle API errors in React components with TypeScript?▼

Wrap the API call in try/catch, check res.status === 'success' for the success path, display res.message for backend failures, and show a user-friendly message in the catch block for network errors. Use a notification store to surface messages to users.

Does the apiClient send Authorization headers automatically?▼

No, the current apiClient does not attach Authorization headers. Authentication is handled on the backend via session cookies, so service functions can call apiClient directly without manual token management.

Do I need to transform snake_case API responses to camelCase?▼

No transformation is needed in the frontend. The backend already converts data to camelCase before sending responses, so fields like clientId and isActive can be used as-is in components.

How do I upload files through the API service layer?▼

Use fetch directly with FormData instead of apiClient, since file uploads require multipart encoding. Do not set the Content-Type header manually; the browser sets it with the correct boundary automatically.