alova

repository·main·Indexed 26 days ago

https://github.com/alovajs/alova

A request strategy layer for JavaScript that sits on top of existing HTTP clients to provide high-level request strategies such as pagination, forms, and uploads. It reduces boilerplate code and supports various UI frameworks including React, Vue, and Svelte. alova features a highly extensible architecture with support for custom request adapters (e.g., Axios, XHR, Taro, UniApp), storage adapters, and state hooks for reactive state management.

Tokens
7.2K
Snippets
12
Records
77
Agent score
87%

What's inside alova

  1. Overview of alova

    main
    alova is a high-performance business logic library designed to bridge the gap between backend APIs and frontend code. It is compatible with your preferred HTTP clients and UI frameworks, enabling efficient API integration, request sharing, and response caching. It provides a type-safe environment and advanced OpenAPI solutions to streamline development.
  2. Overview of alova Request Strategy Layer

    main

    alova is a JavaScript request strategy layer designed to reduce boilerplate code for common request logic. It acts as a layer on top of your existing HTTP client (like axios or fetch), providing 20+ out-of-the-box strategies for tasks like pagination, forms, uploads, and SSE.

    Key Benefits

    • Reduces Boilerplate: Can reduce request-related code by up to 70%.
    • Framework Agnostic: Use the same API across React, Vue, Svelte, Solid, Mini-programs, and Server-side environments.
    • Advanced Strategies: Includes usePagination, useForm, useUploader, and useSSE.
    • Server-side Capabilities: Supports rate limiting and retries (including distributed) via alova/server.
    • Caching: Features multi-level caching (L1/L2) with declarative automatic invalidation using hitSource.
    • OpenAPI Integration: Works with worma to generate type-safe code, TypeScript types, and documentation from OpenAPI specifications.
  3. Submit a Pull Request to alova

    main

    You can contribute code through Pull Requests in three areas:

    1. Bug Fixes: Choose from issues labeled bug:confirmed.
    2. New Features: Choose from issues labeled feature-request:confirmed.
    3. Project Configuration: Improve automation, configuration completeness, or repository management.

    Important Guidelines:

    • Read the Development Guide before starting development.
    • Check if an issue is already claimed by another Pull Request before starting work.
  4. Compare alova with other request libraries

    main

    alova is specifically designed for scenarios requiring complex business logic integration rather than just simple data fetching.

    When to use alova

    • Complex Mid-to-Back-end Systems: Ideal for heavy use of forms, pagination, and file uploads.
    • Cross-platform Development: When you need a single API that works across Web, Mini-programs, uni-app, and Taro.
    • Server-side Request Governance: When you need rate limiting, retries, or distributed request management.
    • OpenAPI Workflows: When you want to transform OpenAPI specs into type-safe code and AI-friendly interface knowledge using worma.

    When to use alternatives (like React Query or SWR)

    • Simple CRUD: If your application only requires basic data fetching and simple caching, libraries like React Query or SWR are sufficient.
  5. Extend alova with custom adapters and strategy libraries

    main

    alova's high extensibility allows you to build your own libraries. Common extension paths include:

    • Custom statesHook: Implement support for different UI frameworks (e.g., solid, qwik). Currently, react, vue, and svelte are supported.
    • Custom Request Adapters: Enable collaboration with other request schemes like GraphQL or SSE.
    • Custom Storage Adapters: Support different environments, such as react-native.
    • Custom Request Strategies: Create reusable, high-performance request strategies for specific business scenarios and publish them to npm.

    If you build a library based on alova, you can submit your project in this issue to have it featured on the official website.