Vue
createClientPlugin
Create a Vue plugin that provides an existing Defjs client via HTTP_CLIENT.
@defjs/vue · Function
Signature
function createClientPlugin(client: DerivableClient): Plugin;
Does not create, cache, or dispose the client — pass the client returned by createClient. Installing it calls app.provide(HTTP_CLIENT, client), so components read the client with injectClient(). The client is stored as given: it is not wrapped in ref, reactive, or markRaw.
Parameters
Prop
Type
client DerivableClientThe client returned by createClient to provide to the app.
Returns
A Vue Plugin for app.use(...).
Examples
import { createClient, withEndpoint } from "@defjs/core"; import { createClientPlugin } from "@defjs/vue"; import { createApp } from "vue"; const client = createClient(withEndpoint("https://api.example.com")); const app = createApp(App); app.use(createClientPlugin(client));