Next.js blog
Three ways to get daily articles into a Next.js site: Markdown committed to your repository, a webhook receiver, or pulling from the REST API at build time.
There are three ways to get articles into a Next.js site. Pick by where your posts live today.
| Your posts live in | Use | You write |
|---|---|---|
| Markdown files in the repository | The GitHub connection | Nothing, if your loader reads front matter |
| A database or headless CMS | The webhook | One route handler |
| Nowhere yet | The REST API | One fetch in a page |
1. Markdown committed to your repository
Connect GitHub under Settings, Publishing with a fine-grained token that has Contents read and write on that one repository. Each article is committed as a file:
content/blog/how-to-choose-a-standing-desk.md
The folder and branch are yours to set. The file starts with front matter:
---
title: "How to choose a standing desk"
description: "…"
date: "2026-11-14T09:00:00.000Z"
slug: "how-to-choose-a-standing-desk"
tags: ["standing desk"]
image: "https://…/api/images/…"
---
The article in Markdown…
image is left out when images are off. A refresh commits to the same path, so the file's history is the article's history. Your normal deploy picks up the commit. Commit to a branch other than main if you want each article as a pull request to review.
2. A webhook receiver
If posts are rows in a database, add one route handler that receives the article and saves it. The webhook page has the payload and a complete handler.
3. Pull from the REST API
For a site with no blog yet, fetch published articles when the page is built:
// app/blog/page.tsx
const API = "https://apexmention.com/api/v1";
const headers = { Authorization: `Bearer ${process.env.CA_API_KEY}` };
export default async function Blog() {
const res = await fetch(`${API}/sites/${process.env.CA_SITE_ID}/articles`, { headers, next: { revalidate: 3600 } });
const { data } = await res.json();
const posts = data.filter((a) => a.status === "published");
return <ul>{posts.map((a) => <li key={a.id}><a href={`/blog/${a.slug}`}>{a.title}</a></li>)}</ul>;
}
The list does not include the body. Fetch each article by id for content_html. The REST API page lists every field.
Which we would pick
Markdown in the repository, if you already have a content folder. You get review by pull request, history for free and no runtime dependency on us. The API route is the quickest to try and the one we would move off first, because your pages then depend on our server answering at build time.