import { usePDF } from 'react-to-pdf';
const Component = () => {
const { toPDF, targetRef } = usePDF({filename: 'page.pdf'});
return (
<div>
<button onClick={() => toPDF()}>Download PDF</button>
<div ref={targetRef}>
Content to be generated to PDF
</div>
</div>
)
}
https://github.com/ivmarcos/react-to-pdf