npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@defjs/vue

v0.0.3

Published

Provide an existing Defjs client to a Vue application.

Readme

@defjs/vue

Thin Vue 3 plugin for @defjs/core: it provides an application-owned client through Vue injection. It adds no transport behavior, state management, retries, or Nuxt module, and never creates, replaces, or disposes a client.

Keeping SDK definitions in their own package means the SDK needs no Vue dependency. Requires Vue 3 or later.

Install

bun add @defjs/core @defjs/vue vue

The package is ESM and requires @defjs/core as a peer in the ^0.6.0 range.

Quick start

// main.ts — application entry point
import { createClient, withEndpoint } from "@defjs/core";
import { createClientPlugin } from "@defjs/vue";
import { createApp } from "vue";
import App from "./App.vue";

const client = createClient(withEndpoint("https://api.example.com"));
const app = createApp(App);

app.use(createClientPlugin(client));
app.mount("#app");

Read the client with injectClient() and own cleanup in the watcher:

<script setup lang="ts">
import { ref, watch } from "vue";
import { injectClient } from "@defjs/vue";
import { getUser } from "./api";

const props = defineProps<{ id: number }>();
const client = injectClient();
const name = ref("");

watch(
  () => props.id,
  (id, _previousId, onCleanup) => {
    const abort = new AbortController();
    onCleanup(() => abort.abort());

    void getUser(client({ signal: abort.signal }), { id }).then(
      ([error, user]) => {
        if (abort.signal.aborted) return;
        if (error) {
          name.value = error.message;
          return;
        }
        name.value = user.name;
      },
    );
  },
  { immediate: true },
);
</script>

<template>
  <div>{{ name }}</div>
</template>

API

createClientPlugin(client): Plugin

Creates a Vue plugin that provides the supplied client as HTTP_CLIENT.

injectClient(key?): DerivableClient

Returns the nearest client for key, defaulting to HTTP_CLIENT. Call it in a valid injection context: synchronous setup() or app.runWithContext() (Vue 3.3+). Throws without an active context or a client for the key; a missing custom key never falls back to HTTP_CLIENT.

HTTP_CLIENT

Public InjectionKey<DerivableClient> for native subtree overrides:

provide(HTTP_CLIENT, createClient(withEndpoint("https://preview.example.com")));

Descendants receive that client; siblings outside the subtree keep the app-level one.

Interceptors and every other client option belong to @defjs/core and are configured before the plugin is installed:

const client = createClient(
  withEndpoint("https://api.example.com"),
  withInterceptors(auth),
);
app.use(createClientPlugin(client));

Notes

  • injectClient() returns the DerivableClient that was provided, a function. Call it with request options where the operation runs to derive a Client value. Pass it straight to createClientPlugin or provide. Do not pass it to watch or computed as the source: Vue calls a function source. Do not wrap it in ref or reactive; the plugin stores it as-is. A derived Client value is not accepted.
  • Create request-specific clients (SSR data with credentials, cookies, or tenant state) at the application boundary.
  • The owner that creates a client also owns its requests, SSE streams, and WebSocket sessions. App unmount does not clean them up.
  • Import createClient, withEndpoint, withInterceptors, and other client options from @defjs/core.

Documentation

License

MIT.