vue-demi
Write Vue libraries that work for both Vue 2 and Vue 3 from a single codebase.
vue-demi
VueWrite Vue libraries that work for both Vue 2 and Vue 3 from a single codebase.
Fit
Bundle (gzip)
305 B
470 B raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Library authors who want to support both Vue 2 and Vue 3 face incompatible imports and APIs, forcing them to maintain separate builds or branches for each major version.
What It Does
vue-demi re-exports the correct Vue APIs for whichever Vue version is installed, so a single library build runs on Vue 2 (with the Composition API plugin) and Vue 3. It is used by VueUse, Pinia, and many other ecosystem packages.
Installation
npm install vue-demiUsage Example
import { ref, computed, isVue3 } from "vue-demi";
export function useCounter(initial = 0) {
const count = ref(initial);
const double = computed(() => count.value * 2);
return { count, double, isVue3 };
}Related packages
A complete component library for Vue 3 with a clean, desktop-oriented design system.
floating-vueVueTooltip, popover, and dropdown directives for Vue 3 — powered by Floating UI with automatic placement and overflow detection.
naive-uiVueFairly complete Vue 3 UI component library — 90+ components with a TypeScript-first design and no dependency on legacy CSS frameworks.
piniaVueThe intuitive, type-safe, and lightweight state management store for Vue — the official successor to Vuex.
@tanstack/vue-queryVuePowerful async state management for Vue — data fetching, caching, background refetching, and server state synchronization.