DEV Community

loading...

Can we make a download button in ReactJs?

vehbirestelica profile image Vehbi Restelica ・1 min read

Hi devs,
I was wondering if there is any option to make a download button with reactjs, so the viewers can download a file.
I wanted to make a "download my resume" button on my portfolio.

Thanks in advance :)

Discussion (3)

pic
Editor guide
Collapse
giseleml profile image
Gisele Leonardi • Edited

Yes you can, all you have to do is pass your download function to the onClick event!

const onDownload = () => console.log('Download')

<button onClick={onDownload}>Download My Resume</button>
Enter fullscreen mode Exit fullscreen mode
Collapse
vehbirestelica profile image
Vehbi Restelica Author

Okay, but is there any library, method to add PDF viewer in react?

Collapse
giseleml profile image
Gisele Leonardi

Yeah of course. The most popular is react-pdf github.com/diegomura/react-pdf