Registry / crm / rest-client-vue

rest-client-vue

JSON →
library1.2.1-bjsnpmunverified

REST API client for Vue.js applications (v1.2.1-b). Integrates with Pinia for state management and Vue 3 Composition API. Provides composable functions for CRUD operations, automatic request deduplication, and reactive data fetching. Ships TypeScript types. Active development with monthly releases.

npm install rest-client-vue
INSTALL
IMPORT
SIG · REST-CLIENT-VUE
R
rest-client-vue
crmjavascriptv1.2.1-b
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

useRestClient
import { useRestClient } from 'rest-client-vue'
import useRestClient from 'rest-client-vue'
Named export, not default. ESM-only.
createRestClient
import { createRestClient } from 'rest-client-vue'
import { createRestClient } from 'vue-rest-client'
Package name is 'rest-client-vue', not 'vue-rest-client'.
RestClientPlugin
import { RestClientPlugin } from 'rest-client-vue'
import { RestClientPlugin } from 'rest-client-vue/lib/plugin'
Subpath imports are not supported; use main entry point.

Shows minimal setup: create a REST client instance, register Pinia, and install the plugin on a Vue 3 app.

import { createApp } from 'vue' import { createPinia } from 'pinia' import { createRestClient, RestClientPlugin } from 'rest-client-vue' const app = createApp(App) const pinia = createPinia() app.use(pinia) const client = createRestClient({ baseURL: process.env.VUE_APP_API_URL ?? 'http://localhost:3000/api', headers: { 'Content-Type': 'application/json' } }) app.use(RestClientPlugin, { client }) app.mount('#app')
Debug
Known issues
breakingv1.0 to v1.1: The `client` option passed to `RestClientPlugin` changed from a factory function to a pre-configured client instance.
fix
Migrate from `app.use(RestClientPlugin, { client: () => createRestClient({...}) })` to `app.use(RestClientPlugin, { client: createRestClient({...}) })`.
affects: >=1.1.0
deprecatedv1.2.0: The `useRestClient` composable's `fetch` method signature changed. Passing a callback as second argument is deprecated; use the `onResponse` option instead.
fix
Replace `useRestClient().fetch('url', (data) => ...)` with `useRestClient().fetch('url', { onResponse: (data) => ... })`.
affects: >=1.2.0
breakingv1.2.1: Removed CommonJS support. Only ESM is provided.
fix
Use `import` syntax instead of `require()`. If you need CJS, stick to v1.2.0.
affects: >=1.2.1
gotchaThe `RestClientPlugin` must be installed after Pinia; otherwise, the client will not have access to the Pinia store.
fix
Ensure `app.use(createPinia())` is called before `app.use(RestClientPlugin, ...)`.
affects: >=1.0.0
gotchaTypeScript users must have `strict` mode enabled in tsconfig for correct type inference.
fix
Set `"strict": true` in your `compilerOptions`.
affects: >=1.1.0
Errors
Common errors & fixes
Cannot find module 'rest-client-vue' or its corresponding type declarations.
Missing TypeScript types or incorrect import path.
fix
Ensure the package is installed: `npm install rest-client-vue`. For TypeScript, verify `node_modules/rest-client-vue` contains `index.d.ts`.
Uncaught TypeError: Cannot read properties of undefined (reading 'state')
Pinia is not installed or not registered before using `useRestClient`.
fix
Install Pinia (`npm install pinia`) and call `app.use(createPinia())` before `app.use(RestClientPlugin, ...)`.
Uncaught RangeError: Maximum call stack size exceeded
Circular reference in reactive data when using `useRestClient` without explicit reactivity opt-in.
fix
Use `shallowRef` or `markRaw` on data objects to avoid deep reactivity on large payloads.
Upgrade
Version history
1.2.1-blatest on npm
Audit
Dependencies
piniarequiredState management integration
vuerequiredVue 3 Composition API and reactivity
Agent activity
41 hits · last 30 days
node
36
Resources
rest-client-vue — npm install rest-client-vue · libregistry