You can find the complete source code for this project on GitHub.
I typically rebuild my portfolio website every year or so to keep up with the latest technologies and best practices. In this blog post, I'll walk you through my experience of building and deploying a portfolio site using Next.js 14 and TypeScript, and hosting it as a static web page on Firebase. I'll cover the technical setup, challenges faced, and the tradeoffs I considered along the way.
I started this project from scratch, opting not to use a template. This gave me full control over the setup and allowed me to understand each piece of the puzzle.
I'm using Next.js 14 with the Pages Router. TypeScript is integrated into all aspects of the project, including components, API routes (if any), and utility functions. This provides excellent type safety and improves the overall development experience.
Here's a snippet of my next.config.js
:
module.exports = {
output: "export",
images: {
unoptimized: true,
},
// other configurations...
};
To generate a static export, I'm using the output: 'export'
configuration in my next.config.js
. This tells Next.js to produce a static HTML export of the app.
An important note: I've had to disable image optimization by setting images: { unoptimized: true }
. This is a requirement when using output: 'export'
, as Next.js's built-in Image Optimization cannot function without a Node.js server.
While disabling image optimization is necessary for static exports, it's not ideal for performance. As an alternative, you could consider:
These approaches can help mitigate the performance impact of unoptimized images in a static export.
My deployment workflow is straightforward:
next build && firebase deploy --only hosting
This command builds the Next.js project and then deploys it to Firebase Hosting. The simplicity of this process is one of the main advantages of this setup.
Before settling on Firebase Hosting, I explored a couple of other options:
Firebase Hosting stood out for several reasons:
While this setup works well for my portfolio, it's worth noting some limitations:
Deploying a Next.js static site to Firebase has provided me with a cost-effective, low-maintenance solution for my portfolio. The combination of Next.js's powerful development features, TypeScript's type safety, and Firebase's simple hosting has resulted in a setup that's both developer-friendly and performant.
While there are tradeoffs, particularly around dynamic capabilities and image optimization, the benefits outweigh the drawbacks for my specific use case. This approach allows me to focus on creating content and improving my portfolio without worrying about complex infrastructure or high hosting costs.