Skip to main content

Hook-Fetch ๐Ÿš€

Welcome to Hook-Fetch! A modern HTTP request library based on the native fetch API, providing clean syntax, rich features, and a powerful plugin system.

Featuresโ€‹

  • ๐Ÿš€ Modern Design - Based on native fetch API, supports Promise and async/await
  • ๐Ÿ”Œ Plugin System - Powerful plugin architecture with custom extensions
  • ๐ŸŒŠ Streaming Support - Perfect support for SSE (Server-Sent Events) and streaming data
  • ๐ŸŽฏ TypeScript Support - Complete type definitions and type inference
  • ๐Ÿ”„ Request Retry - Built-in request retry mechanism
  • ๐Ÿ›ก๏ธ Error Handling - Comprehensive error handling and exception catching
  • ๐ŸŽจ Framework Integration - React and Vue Hook support
  • ๐Ÿ“ฆ Lightweight - Small size with no extra dependencies
  • ๐Ÿ”ง Highly Configurable - Flexible configuration options for various needs

Quick Startโ€‹

Installationโ€‹

# Using npm
npm install hook-fetch

# Using yarn
yarn add hook-fetch

# Using pnpm
pnpm add hook-fetch

Basic Usageโ€‹

import hookFetch from 'hook-fetch';

// GET request
const response = await hookFetch('https://api.example.com/users').json();
console.log(response);

// POST request
const newUser = await hookFetch('https://api.example.com/users', {
method: 'POST',
data: { name: 'John', email: 'john@example.com' }
}).json();

Create Instanceโ€‹

// Create a configured instance
const api = hookFetch.create({
baseURL: 'https://api.example.com',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer your-token'
},
timeout: 5000
});

// Use the instance
const users = await api.get('/users').json();

Why Choose Hook-Fetch?โ€‹

Advantages over other librariesโ€‹

  • vs Axios: More lightweight, based on modern fetch API, better TypeScript support
  • vs Native fetch: Cleaner API, built-in error handling and retry mechanism
  • vs Other fetch libraries: Unique plugin system and streaming support

Use Casesโ€‹

  • Modern web application development
  • Scenarios requiring streaming data processing
  • Projects sensitive to bundle size
  • Highly customizable request processing needs
  • Data fetching in React/Vue projects

Next Stepsโ€‹

Community and Supportโ€‹

Let's start exploring the powerful features of Hook-Fetch!