A portfolio site with an “About Me” card and a “Download Resume” button (PDF stored in Firebase).
I’m continuing to build my website and recently added an "About Me" section. This section includes a simple card component featuring my photo and a brief paragraph introducing myself. I also plan to include a "Download Resume" button that triggers the download of my resume when clicked.
Here are the steps I followed to set this up:
npm install firebase
npm install --save-dev @types/firebase
Even if you only need storage, you must create a Firebase app. (Note that depending on how many apps you have in Firebase, you may need to add a payment method.)
.env
FileMake sure to include your Firebase configuration keys (e.g., apiKey
, authDomain
, projectId
, storageBucket
, etc.) in a .env
file. For example:
Create a configuration file (e.g., firebase.js
or firebase.ts
) and initialize Firebase using the environment variables:
In the Firebase Console, under Build > Storage > Rules, update rules to allow public read access to your file:
Generate a download URL in your server or serverless function. This URL contains a token that authorizes access. For instance, in Next.js:
When the user clicks the "Download Resume" button, fetch the download URL from your API and initiate the download:
If you deploy your app (e.g., on Netlify, Vercel, etc.), make sure you add the same environment variables there so the app can access Firebase in your production environment.