vue-qrcode is a Vue.js component designed for generating QR codes directly within Vue applications. It serves as a declarative wrapper around the popular `qrcode` library (github.com/soldair/node-qrcode), abstracting away the complexities of direct canvas or SVG manipulation. The package is currently at version 2.2.2 and maintains an active development cycle, with recent patch and minor releases addressing fixes and new features. It differentiates itself by offering a Vue-idiomatic interface to robust QR code generation, supporting a wide array of customization options including version, error correction level, quiet zone margin, scaling, exact width, and customizable dark and light module colors. It's compatible with both Vue 2.7+ and Vue 3.0+ environments, making it suitable for modern Vue projects.
npm install vue-qrcodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to integrate the VueQrcode component into a Vue SFC, bind a value, pass options, and capture the generated data URL via the `change` event.
Upgrade your Vue project to Vue 2.7.0+ or Vue 3.0.0+. Alternatively, use `vue-qrcode` version 1.x if stuck on older Vue versions.
If upgrading from `vue-qrcode` versions older than 2.1.0, review the `qrcode` library's changelog for any breaking changes or behavior modifications that might impact your QR code generation.
Ensure both `vue` (matching the peer dependency range) and `qrcode` (`^1.0.0`) are explicitly installed in your project's `dependencies` or `devDependencies` using `npm install vue qrcode` or `yarn add vue qrcode`.
Verify that your bundler (e.g., Webpack, Rollup, Vite) is configured to correctly process ESM imports. For Node.js environments, consider setting `"type": "module"` in your `package.json` for files using ESM syntax.
Ensure `VueQrcode` is imported and added to the `components` option of your Vue component, e.g., `components: { VueQrcode }`. For global registration in Vue 3, use `app.component('VueQrcode', VueQrcode)`.Install the required `qrcode` package: `npm install qrcode` or `yarn add qrcode`. Verify its version meets the `vue-qrcode` peer dependency requirement.
Always provide the `value` prop to the `<vue-qrcode>` component, as it defines the data to be encoded. Example: `<vue-qrcode :value="myQrCodeData" />`.
Ensure your bundler is configured to handle ESM modules. If in Node.js, confirm your project's `package.json` has `"type": "module"` if you are using ESM syntax, or consider dynamic `import()` for CJS contexts.