In this article
Most of the Next.js sites I've worked on didn't start with a blog. They started as a product site, a docs site or an app with a marketing front end, and six months later someone asked for "just a few articles". You then have three realistic options, and only one of them means signing up for another service. This post compares them and explains how to run a Next.js blog without a headless CMS when the people writing the posts aren't developers.
The short version. MDX in the repo is great until a non-developer needs to publish. A headless CMS fixes that, at the cost of a second system with its own content model, its own bill and its own outages. A posts table in your own Postgres database sits in between. It's the option people skip, because it seems to need an admin screen you'd have to build yourself.
Three ways to add a blog to an existing Next.js site
MDX files in the repo
Posts live in something like content/posts/*.mdx. At build time you read the folder, parse the frontmatter and render each file, usually with @next/mdx or next-mdx-remote.
What's good about it:
- No infrastructure. Posts are files, versioned in git and reviewed in pull requests like any other change.
- Fully static output. Pages build once and are served from the CDN.
- You can drop React components into a post: a pricing calculator, a live demo, an interactive chart.
Where it hurts:
- Publishing is a deploy. A one-word typo fix means a commit, a build and a wait. On a medium-sized site that's a few minutes. On a site with thousands of pages it's longer.
- The writer needs git, or a developer has to paste their Google Doc into a file. The second arrangement is how most MDX blogs actually run, and it's why so many of them stop being updated after the third post.
- Scheduling means a scheduled build (a cron job calling a deploy hook) or a date check in code that still needs a rebuild at the right moment.
- Images pile up in
public/and the repo keeps growing.
If you're a developer writing your own blog, MDX is the right answer and I won't try to talk you out of it.
A headless CMS: Contentful, Sanity, Strapi
The content lives in a separate service. Editors get a proper interface, and your Next.js app fetches posts through an API at build time or on request.
Credit where it's due. Contentful has mature roles, environments and localization, and larger content teams often know it already. Sanity's Studio is very customizable, and its structured rich text works well when the same content feeds a site, an app and an email. Strapi is open source and self-hostable, so the data can stay on your own server. All three publish solid Next.js examples. For a content-heavy site where the content is the product, a headless CMS is often the right call.
The costs are real, though:
- A second source of truth. If your site already runs on Postgres (users, products, docs), the posts now live somewhere else. Showing "posts by this author" next to your own
userstable becomes an API call plus glue code. - A migration. You model content types, move the existing posts, rewrite the blog pages to use the CMS SDK and wire up webhooks for cache revalidation. On an existing site that's days of work, not an afternoon.
- Pricing tied to seats, locales or API usage. Free tiers are generous at first. Read the current pricing pages before you commit, because limits change.
- Another dependency on the request path, unless every page is built statically.
Posts in your own Postgres table
You add a posts table, or you already have one. Your pages query it directly, the same way they query everything else. It's the most boring setup of the three, and it's how I'd run a Next.js blog without a headless CMS on any app that already uses Postgres.
- Posts sit next to the rest of your data. One backup, one set of credentials, plain SQL joins.
- Pages render with whatever you already use:
pg, Prisma, Drizzle. - Publishing is a row update. No deploy.
The catch is obvious. Someone has to write the rows. Developers can do it with SQL or a seed script, and editors can't. So teams either build a small admin page, which quietly turns into a project (auth, a rich-text editor, image uploads, drafts, scheduling), or they give up and buy a CMS anyway.
MDX vs headless CMS vs database, side by side
| MDX in the repo | Headless CMS | Postgres table | |
|---|---|---|---|
| Where posts live | Git | The vendor's database, or your Strapi server | Your database |
| Who can publish | People comfortable with git | Anyone with a CMS login | Developers, unless you add an editor |
| Time from publish to live | A full build and deploy | Seconds, with a webhook that revalidates | Seconds, with revalidation |
| Drafts and scheduling | Branches, scheduled builds | Built in | Whatever you build or plug in |
| Joins with your own data | No | Through API calls | Plain SQL |
| Extra service to run or pay for | None | Yes | None |
| Effort on an existing site | Low | Medium to high | Low if the table exists |
The Postgres column looks best on paper except for one row: who can publish. That's the gap worth closing.
Let non-developers publish to Next.js without a CMS migration
That gap (a perfectly good posts table, but no editor in front of it) is what we built the Next.js connector in Quillfleet for. Editors write in Quillfleet, in Markdown or a visual editor. Your site installs @quillfleet/connector-next and adds a single route file. The connector receives each post from Quillfleet and writes into the table you already have, using your column names.
It adds one small table of its own, hub_post_links, to remember which rows it created. It never alters your table. It also never overwrites a post it didn't create: if the slug already belongs to one of your own rows, Quillfleet reports a slug_conflict and your row stays exactly as it was.
Your blog pages don't change. They keep running the same SELECT against the same table.
Here's the route file for a site whose table is called articles and uses its own column names:
// app/api/hub/[...path]/route.ts
import { createHubHandler, createPostgresStore, fromPgPool } from "@quillfleet/connector-next";
import { revalidatePath } from "next/cache";
import { pool } from "@/lib/db"; // the pg Pool your site already uses
export const { GET, PUT, DELETE } = createHubHandler({
secret: () => process.env.HUB_SECRET,
postUrl: (slug) => `${process.env.SITE_URL}/blog/${slug}`,
onChange: (event) => {
revalidatePath("/blog");
if (event.slug) revalidatePath(`/blog/${event.slug}`);
if (event.type === "upsert" && event.previousSlug) {
revalidatePath(`/blog/${event.previousSlug}`);
}
},
store: createPostgresStore({
db: fromPgPool(pool),
table: "articles",
columns: {
slug: "slug",
title: "headline",
contentHtml: "body_html",
excerpt: "summary",
coverImageUrl: "hero_image",
publishedAt: "published_at",
updatedAt: "updated_at",
},
status: { column: "is_published", published: true, draft: false },
}),
});
A few details that matter in practice:
- Only
slug,titleandcontentHtmlare required. Map the rest if you have the columns:metaTitle,metaDescription,canonicalUrl,ogImage,noindex, andcategoriesandtagsastext[]columns. That's how a Next.js site receives every SEO field from the editor. - Without a
statusmapping the site can't hold drafts, and unpublishing a post removes the row instead. - If your table has other required columns, such as
site_idin a multi-tenant app, theextraValuesoption fills them in. - Every request is signed with the site's own secret,
HUB_SECRET, and expires after 5 minutes. Anything else is refused before the database is touched. Keep the secret server-side and never give it aNEXT_PUBLIC_prefix. - You need the App Router (Next.js 13.4 or later), the Node.js runtime for that route, and
zodv4.
If your posts aren't in a single table (Prisma models with relations, say, or files), get in touch and we'll help you set it up. The full walkthrough, including media uploads and previewing posts in your site's own design, is in the Next.js connector setup guide. For a side-by-side look at every way a site can connect, see the connectors page.
Revalidation and ISR for a Next.js blog with Postgres
This is where database-backed blogs trip people up, with or without Quillfleet. If /blog/[slug] is statically generated, a new row in Postgres changes nothing until that page is regenerated. Editors click publish, refresh the site, see nothing, and file a bug.
You have three reasonable choices:
- Render on request. Put
export const dynamic = "force-dynamic"on the blog pages and every request queries the database. For a blog with modest traffic and an index onslug, this is fine. - Cache, then revalidate on demand. Keep the pages cached and call
revalidatePathwhen a post changes. That's whatonChangein the snippet above is for. It runs after each committed write, so the list page, the post page and the old URL (when an editor renames a slug) are refreshed together. - Time-based ISR.
export const revalidate = 300regenerates a page at most every five minutes. It's simple, but an edit can take that long to show up, and a removed post lingers for the same window.
I'd use the second option, with a long time-based revalidate as a safety net. Two things to watch. Revalidation is per path, so if posts also appear on your home page or a category page, revalidate those paths too. And errors thrown inside onChange are logged on your side, never sent back to the hub, so Quillfleet will show the post as Live even if your cache didn't refresh. Check your server logs first when a post "isn't there".
Caching defaults in Next.js have changed between major versions, so read the caching section of the Next.js docs for the version you actually run.
When a Next.js blog without a headless CMS is the wrong choice
I'd steer you away from this setup in a few cases:
- You're the only writer and you like git. Use MDX. It's less to run.
- Your posts embed live React components. HTML in a column can't do that. MDX can.
- You need structured content reused across an app, emails and the site, or heavy translation workflows. That's exactly what a headless CMS is built for.
- You have no database and don't want one. Standing up Postgres for twenty articles is overkill.
And some limits of Quillfleet itself. The post body is the same on every site you publish it to, so if each site needs a different article, it's the wrong tool. It doesn't import existing posts yet either. Your old posts stay in the table and keep rendering as before, and Quillfleet only manages the ones it creates.
A setup checklist for an existing Next.js site
If you've decided to run your Next.js blog without a headless CMS, on your own Postgres, this is the order I'd follow:
- Check the posts table has a unique
slug, atitleand an HTML body column. Add a status column if you want drafts. - Decide how pages render: dynamic, or cached with
revalidatePath. - Install the connector, add the route file, and set
HUB_SECRETandSITE_URLlocally and in your host's environment settings for production. - Let
/api/hub/*through any auth middleware. The connector checks every request itself. - Deploy, then click Test connection on the site's page in Quillfleet.
- Publish a draft first, look at the row in the database, then publish for real.
If you also run WordPress sites, the same post can go to both from one editor. See how to publish one blog post to multiple websites for that side of it. The 30-day free trial covers five sites, which is enough to try the connector on a staging copy before it touches production.
Frequently asked questions
Can I use Postgres as the CMS for a Next.js blog?
Yes. A posts table with a slug, a title, an HTML or Markdown body and a status column is enough for most blogs. Your pages query it like any other table. What Postgres doesn't give you is an editing screen, so you either build one, let developers write rows by hand, or connect an external editor that writes into the table for you.
Is MDX a good choice if the writers aren't technical?
Usually not. MDX works well when the person writing is comfortable with git and pull requests. With non-technical writers, a developer ends up copying drafts into files and running deploys, and that bottleneck tends to slow the blog down until it stops. If writers need to publish on their own, use a CMS or an editor that writes to your database.
Do I need ISR for a blog that reads from a database?
Not necessarily. Rendering blog pages on every request is fine for modest traffic if the slug column is indexed. If you want cached pages, use on-demand revalidation when a post changes, so new posts appear within seconds. Time-based revalidation alone works, but edits and removals can take as long as the revalidate window to show.
How long does it take to add a blog to an existing Next.js site?
With MDX, an afternoon for a basic list and post page. With a headless CMS, expect a few days once you count content modelling, migration and webhooks. With an existing Postgres table and a connector, the route file itself takes minutes, and most of the time goes into checking column mappings and caching behaviour.
Does storing blog posts in a database hurt SEO compared to static files?
No. Search engines see the rendered HTML, not where it came from. A server-rendered or cached page from Postgres looks the same to a crawler as a static page built from MDX. What matters is that pages load quickly, return the right status codes, and carry proper titles, descriptions and canonical tags.
- Next.js blog without a headless CMS
- add a blog to an existing Next.js site
- Next.js blog with Postgres
- MDX vs headless CMS vs database
- let non-developers publish to Next.js
