vue-uuid is a specialized library for integrating UUID generation capabilities directly into Vue.js applications. The current stable version, 3.0.0, exclusively supports Vue 3, with previous versions like 2.1.0 available for Vue 2 compatibility. It provides convenient access to UUID generation methods (v1, v3, v4, v5) directly on the Vue instance via `$uuid`, making them readily available within component templates and scripts. Additionally, it exports a standalone `uuid` object for use outside the Vue instance. While many general-purpose UUID libraries exist, vue-uuid differentiates itself by streamlining the integration specifically for the Vue ecosystem, abstracting away common setup boilerplate and providing a consistent API within the Vue context. Its release cadence appears to be tied to major Vue version updates, ensuring compatibility with the latest framework changes.
npm install vue-uuidVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to install `vue-uuid` by wrapping `createApp` with `withUUID` and then accessing UUID generation methods via `$uuid` within a component's template and script.
For Vue 2 projects, downgrade to `npm i vue-uuid@2.1.0`. For Vue 3 projects, ensure your Vue version is 3.0.0 or higher.
Update direct references to the new bundle names: `dist/vue-uuid.es.js` -> `dist/index.esm.js`, `dist/vue-uuid.cjs.js` -> `dist/index.js`, `dist/vue-uuid.js` -> `dist/index.umd.js`.
Prefer ES Module `import` syntax (e.g., `import withUUID from 'vue-uuid';`) over CommonJS `require()` where possible, especially in modern Node.js or bundler setups.
Ensure `withUUID` wraps your `createApp` call correctly: `const app = withUUID(createApp(...));`. Also verify that your Vue version is compatible with the `vue-uuid` version you are using (v3.0.0+ for Vue 3).
Ensure `vue-uuid` is correctly installed and that your `tsconfig.json` includes `vue-uuid` in its type roots or references. Sometimes, restarting the TypeScript server or IDE can resolve type inference issues.
Do not use `app.use(withUUID)`. Instead, wrap your `createApp` call directly: `const app = withUUID(createApp({ ... }));`.