A lightweight request strategy library, which provides targeted request strategies for different request scenarios to improve application availability and fluency, reduce server pressure, and enable applications to have excellent strategic thinking like a wise man.
English | 📑中文
- 🕶 Provide a unified experience in the vue, react, and svelte, and seamlessly transplant
- 📑 The api design is similar to axios, more simple and familiar
- 🍵 Out-of-the-box high-performance request strategy, making the application smoother
- 🐦 4kb , only 30% of axios
- 🔩 High flexibility, compatible with any request library, such as axios, superagent or fetch-api
- 🔋 3 data cache modes to improve request performance and reduce server pressure
- 🔌 Rich extension functions, you can customize request adapter, storage adapter, middleware, and states hook
- 🖥️ [2.2.0 ]Server-side rendering(SSR)
- 💕 Request sharing to avoid sending the same request at the same time
- 🪑 Data pre-fetching, which means users can see information faster without waiting
- 🦾 Real-time automatic status management
- 🎪 Interactive documentation and examples
- 🎈Typescript support
- ⚡ Support tree shaking, which means that the production volume of alova is often less than 4kb
Alova is the core library, which provides common functions such as caching strategy, request sharing strategy, and state management, and can meet more than 95% of request requirements. At the same time, alova also provides business logic and frequently used request strategy hooks, which can be directly used in specific scenarios. The following is a list of request policy hooks provided by alova.
Name | Description | Documentation |
---|---|---|
Paging request strategy | Automatically manage paging data, data preloading, reduce unnecessary data refresh, improve fluency by 300%, reduce coding difficulty by 50% | usePagination |
Non-inductive data interaction strategy | A new interactive experience, submitting and responding, greatly reducing the impact of network fluctuations, making your application still available when the network is unstable or even disconnected | useSQRequest |
Form Submission Strategy | A hook designed for form submission, through which you can easily implement form drafts, multi-page (multi-step) forms, in addition to providing common functions such as form reset | useForm |
Send Verification Code | Verification code sending hook, which saves you the trouble of developing the verification code sending function. | useCaptcha |
Cross-component trigger request | An alova middleware that removes the limitation of component hierarchy and quickly triggers the operation function of any request in any component | actionDelegationMiddleware |
serial request useRequest | A more concise and easy-to-use serial request use hook than alova's serial request method, providing a unified loading Status, error, callback function | useSerialRequest |
Serial request useWatcher | A more concise and easy-to-use serial request use hook than alova's serial request method, providing a unified loading Status, error, callback function. | useSerialWatcher |
Request Retry Strategy | Automatic retry on request failure, it plays an important role in important requests and polling requests | useRetriableRequest |
If you still have a specific and typical business request scenario, but we have not implemented it yet, you can submit an issue to tell us here, we Will make it available to more people. You can also customize the request hook, please see the Advanced section.
The examples here will show the power of alova.
The original intention of alova is to propose a solution for different request scenarios. It can implement request functions with better experience and performance more concisely and elegantly. It is an RSM implementation library, such as $.ajax, axios and fetch-api. It provides good support for request sending and response receiving. They are an indispensable part of the RSM process (request event link), and alova still needs to rely on them for requests, so we can regard alova as a request library. An armament that makes the request library even more powerful.
It has been nearly a year since the development of the first version of alova. During this year, we have been continuously discovering and optimizing problems. So far, alova has passed 160 unit tests, with a coverage rate of 99%. Even so, alova is still a rookie, so I suggest you use it conservatively.
I promise to solve it as soon as possible after receiving your issue
If you like alova. we are very appreciate your star at the topright. it's a approval of our work.
alova is a request strategy library, which was originally created to provide specific request strategy solutions for different request scenarios, so as to achieve a smooth request experience more concisely and elegantly, such as $.ajax
, axios
and fetch- api
, etc. provide good support for request sending and response receiving, they are an essential link (request event) in the RSM process, alova still needs to rely on them to make requests, Therefore, we can regard alova as an arm of the request library, making the request library more powerful.
Decoupling a js library means using it in more scenarios. For example, axios can be used in nodejs, but it also means that developers need to write more template code, such as using useHooks to encapsulate axios. However, alova abandons more usage scenarios brought about by decoupling, and positions the scope of use in conjunction with the UI framework to use alova in the most streamlined way. This is for the benefit of developers and is prevalent in a UI framework. Sometimes, deep binding can provide developers with direct-use functions and improve the developer's experience without requiring too much template code.
alova | axios | react-query | vue-request | vue | react |
---|---|---|---|---|---|
Click here to view the detailed introduction
# use npm
npm install alova --save
# use yarn
yarn add alova
If you have thought of some specific and typical business request scenarios, you can submit an issue to tell us here, and we will implement it for More people use.
Resources | Description |
---|---|
@alova/mock | Mock request adapter for alova.js |
@alova/scene-react | react request strategy library for alova.js |
@alova/scene-vue | vue request strategy library for alova.js |
@alova/scene-svelte | svelte request strategy library for alova.js |
@alova/adapter-uniapp | uniapp adapter for alova.js |
@alova/adapter-taro | taro adapter for alova.js |
@alova/adapter-axios | axios adapter for alova.js |
@alova/adapter-xhr | XMLHttpRequest adapter for alova.js |
- ✅ The storage time can be set as a date object, indicating that it expires at a certain point in time
- ✅ You can set the default cache for different request methods globally. The current default is 500 seconds of memory cache for GET requests
- ✅ Additional state management, get and update additional state across pages and modules
- request error log printing
- ✅ Complete offline submission function, you can submit when you are offline, and you can read offline information when you enter again
- ✅ Request middleware design, which can manually control sending requests, status modification, etc.
- ✅ Retry interval, maximum number of retries, etc. when silent submission fails
- ✅ Request to share
- ✅ Server-side rendering support
- Performance improvements
- ✅ Adapters for each operating environment (Uniapp, Taro)
- Develop extended hooks under different request scenarios through alova/scene library, providing out-of-the-box high-performance and high-experience functions [Refer to usePagination ]
Please make sure to read the Contributing Guide before making a pull request.
If you encounter difficulties when using alova, whether it is a bug, or an unmet feature, you can submit an issue.