ahooks-vue is a comprehensive collection of Vue Composition API hooks, designed to simplify common logic and stateful operations in Vue 2 (specifically 2.7+) and Vue 3 applications. Many of its hooks are direct ports and adaptations from the popular React hooks library, ahooks, offering a familiar API for developers transitioning or working across both ecosystems. Currently at version 0.15.1, the library sees a consistent, though not strictly scheduled, release cadence, with minor versions frequently bringing new features and bug fixes. Its key differentiators include broad compatibility achieved through `vue-demi`, enabling a single codebase for both major Vue versions, and full TypeScript support, providing predictable static types for enhanced developer experience and code maintainability. It aims to provide a robust and production-ready set of utilities for common patterns like state management, async requests, DOM operations, and more, similar to `vue-use` but with a distinct API influence from `ahooks`.
npm install ahooks-vueVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to fetch data asynchronously using the `useRequest` hook with Axios in a Vue 3 component. It shows manual execution, loading state, error handling, and data display.
Remove all references to `useOLAP`. If its functionality is still needed, a custom implementation or an alternative utility must be found or developed.
Ensure your Vue 2 project is updated to at least Vue 2.7 to guarantee full compatibility and access to Composition API features required by ahooks-vue.
Install axios using your package manager: `npm install axios` or `yarn add axios`.
Review your `tsconfig.json` for appropriate settings that support modern JavaScript modules and Vue's Composition API types. Ensure `vue-tsc` is used for proper type checking in Vue projects.
Check the official documentation or release notes for available hooks. For instance, `useOLAP` was removed in v0.14.0.
Run `npm install axios` or `yarn add axios` in your project directory.
Ensure your project is configured for ES Modules (e.g., `"type": "module"` in `package.json` for Node.js, or a bundler like Vite/Webpack is correctly transpiling modules for browsers). If stuck with CJS, you may need dynamic `import()` or reconsider the module setup.
Verify that `vue-demi` is correctly installed and configured. For Vue 2, ensure components using Composition API are registered appropriately (e.g., using `Vue.extend` or through a build setup that handles Vue 2 Composition API transpilation).