skills/smithery.ai/React API Layer Architecture

React API Layer Architecture

SKILL.md

React API Layer Architecture

A consistent API layer is crucial for preventing "spaghetti code" in asynchronous logic. This document outlines the standards for handling data fetching in this project.

1. Core Principles

  1. Centralized Configuration: Never call fetch or axios.get directly in a component. Always use the configured HTTP client.
  2. Typed Responses: Every API call must return a typed response (or Zod schema validated data).
  3. Hooks for Data Access: Components (or their ViewModels) consume Hooks (useGetUser), not Promises (api.getUser()).
  4. Error Normalization: Errors should be caught and formatted in the global interceptor before reaching the UI layer.

2. Directory Structure

Installs
First Seen