Vue-to-print is a JavaScript library providing a Vue 3 component and composable hook designed to facilitate printing the content of any DOM element or Vue component. It aims to offer a consistent API experience with its React counterpart, ReactToPrint. Currently stable at version 1.5.1, the library demonstrates an active release cadence, with several updates including minor features and bug fixes throughout the last year. Key differentiators include its direct lineage from ReactToPrint, ensuring a familiar API for developers transitioning between frameworks, and robust TypeScript support, making it suitable for modern Vue 3 applications that prioritize type safety. It focuses on rendering content to a new print window while retaining original CSS styles.
npm install vue-to-printVerified import paths — ran on the pinned version, not inferred.
Demonstrates printing a specific DOM element's content using the `usePrint` composable and a ref.
Upgrade to v1.2.0-alpha.3 or higher to resolve potential dependency conflicts related to `@vue/composition-api`.
Ensure you are on v1.3.1 or later. If on an older version and facing issues with print event data, try removing `toValue()` calls if they seem redundant or cause issues.
Review the package's dependencies and generated bundles for any unexpected changes or additions, particularly if bundle size or external network requests are a concern.
Update to v1.1.1 or newer. If maintaining older versions, manually check and adjust TypeScript configurations (`tsconfig.json`) or custom type declarations if you encounter type conflicts.
Update `vue-to-print` to version `1.3.1` or newer. Remove explicit `toValue()` calls from print event handlers, as the values are now directly accessible.
Upgrade `vue-to-print` to version `1.2.0-alpha.3` or later. If the issue persists, ensure your project's `package.json` correctly specifies `vue` as a peer dependency matching the library's requirements (`^3.0.0`).