Next.js · Caching · Lessons
Rebuilding my portfolio on Next.js 16: what broke and what I learned
Kamruzzaman Akash · · 2 min read
I rebuilt this portfolio from scratch on the latest Next.js. I expected a redesign. I got a crash course in how much the framework has changed, plus a reality check on my own project links.
Here are the four things worth writing down.
1. revalidate is gone when Cache Components is on
New Next.js 16 projects ship with cacheComponents: true. My old GitHub route started with the line I had copied into every project for years:
export const revalidate = 3600;
The dev server refused to compile it. With Cache Components, route segment config like revalidate and dynamic is not allowed. Caching moves into the code that does the work:
import { cacheLife } from "next/cache";
async function getGithub() {
"use cache";
cacheLife("hours");
// fetch profile, repos and contributions…
}
export async function GET() {
return Response.json(await getGithub());
}
Two details tripped me up. A "use cache" function must return plain data, not a Response, because the result gets serialized. And "use cache" cannot sit directly inside a route handler body, so it has to live in a helper.
2. Don't cache a failure
The GitHub API allows 60 unauthenticated requests an hour. Restart a dev server enough times and you hit that limit. If your cached function quietly returns an empty object when GitHub says no, you have just cached "nothing" for an hour.
The fix is to throw instead:
if (!user && repos.length === 0) throw new Error("github unreachable");
A thrown error is not cached, the route returns a 502, and the UI shows a friendly "GitHub isn't answering right now" with a link to my profile. In production I set a GITHUB_TOKEN, which raises the limit a lot.
3. A hydration mismatch I didn't write
React kept warning that a server-rendered <img> had loading="eager" while the client wanted loading="lazy". It was an ordinary next/image with fill. Setting loading explicitly to the same value on both sides made the warning go away. The lesson: when a warning points at framework output, look at the props you didn't set.
4. Most of my live demos were dead
This one stung. While building the work section I took screenshots of every live project. Six of the eight links returned a 404 or a "Site Not Found" page. Free-tier deployments get paused, projects get renamed, and nobody checks.
So the portfolio now only links to things that load, and projects without a working deployment get a designed cover instead of a fake screenshot. A broken demo link costs more trust than no link at all.
The takeaway
Framework upgrades are mostly about moving the same ideas into new places: caching moved from route config into functions. Portfolios are mostly about trust. Check your links.
Keep reading
All postsDesigning an escrow flow for AssignMate
· 2 min read
How I think about money moving between two strangers: a strict assignment lifecycle, a server that owns every transition, and payment callbacks that can arrive twice.
Offline-first in React Native: notes from MoneyMate
· 2 min read
An expense tracker is useless if it can't save a coffee without signal. What offline-first really means, and the pattern I follow with Expo and Supabase.