I have a create-react-app project in which I want to link to a pdf file I have saved in my project. I suppose my questions are twofold:
1) I'm not sure where exactly I need to save the PDF file (src folder vs public folder)
2) How do I properly link to the pdf file? Right now I have something like this:
<a href="/portfolio-revamp/public/documents/resume.pdf">Resume</a>
and it's not displaying - it changes the URL but doesn't take you to the PDF.
Any advice greatly appreciated!
You need to have the file in the public folder. If you want it to open in a browser, that's what it will do. If you want to force users to download, you can add the 'download' attribute to the anchor tag.
src/
, for example src/static/my-file.pdf
.import myFile from "./static/my-file.pdf";
(path is relative to src/
).a
tag: <a href={myFile}>Link to My File</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With