Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PDF download in Nextjs

Is it possible to have a button/link that will trigger download PDF on click?

I am creating a portfolio, and have one part where u need to download my CV, is it possible, and how if it is?

like image 929
Nedim Avatar asked Oct 20 '25 05:10

Nedim


2 Answers

Yes! It is possible, the first thing to have in mind is where are you going to host the pdf that you are going to download. You can have it as an asset on your webpage or in a storage bucket from any of the major providers then just add the following snippet.

<a href='assets/my_pdf.pdf' download>Download pdf</a>

And you would replace assets/my_pdf.pdf with the url pointing to your file.

like image 55
Tomás Rivera H. Avatar answered Oct 21 '25 19:10

Tomás Rivera H.


In Nextjs 13 (I'm not sure if it's the same in other versions) you would need to place your pdf file in the public directory of your project. Then you can use a simple <a> tag like so <a href="/resume.pdf" download>Download</a>

For reference check out this discussion on github

like image 23
Pachuca Avatar answered Oct 21 '25 19:10

Pachuca