October 30, 2024
·
6 min read
·By Mostafa Aljazar

Building a Portfolio CMS with Next.js and Local JSON

Who says you need a database for a personal portfolio? Here's how I built a fully featured CMS using JSON files, server actions, and Next.js caching.

Most portfolio tutorials reach for a database immediately. But for a personal site with a single admin, a database adds infrastructure overhead without meaningful benefit. JSON files on the filesystem, with Next.js server actions and revalidatePath, give you the same DX with zero ops burden.

The Data Layer

Two utility functions — readData<T>(filename) and writeData<T>(filename, data) — wrap fs.promises.readFile and writeFile. Every domain module (projects.ts, skills.ts, blogs.ts) calls these with typed generics. Consistent, simple, and easy to swap for a real database later.

Cache Invalidation with revalidatePath

After every write, call revalidatePath('/') and the relevant sub-path. Next.js purges the cached RSC payload, and the next page load reflects the update instantly. No polling, no webhooks, no complexity.

When to Graduate to a Database

If you need multiple concurrent editors, row-level access control, full-text search, or a deployment platform that doesn't support writable filesystem, it's time for a database. Until then, JSON files are perfectly fine — and they're trivially version-controlled in git.

Mostafa Aljazar

Frontend Developer passionate about crafting performant, accessible, and beautiful web experiences with React.js and Next.js.

Let's build something amazing together

Connect

iconicon

© 2026 Mostafa Aljazar. All rights reserved.

Built with Next.js & Tailwind CSS