5 min read
How to publish blog content to a Next.js site
Compare three ways to push approved content to a Next.js site automatically: MDX files, signed webhooks, and deploy hooks, with steps for each and when to pick it.
You can publish to a Next.js site automatically in three ways: commit MDX files to the repo, receive content through a signed webhook, or trigger a rebuild with a deploy hook. MDX files suit developer-run blogs, a signed webhook suits content that arrives from another system, and a deploy hook suits sites that rebuild statically from a content source. Pick one based on where your content lives and how fast it needs to go live.
Which publishing path fits your site?
Choose by where the content is stored and who triggers the release. The three paths differ in what moves, what runs, and what you must build yourself.
| Path | What moves | What you build | Best for |
|---|---|---|---|
| MDX files | The finished page as a file in your repo | A route that reads and renders MDX | Sites where developers review every change |
| Signed webhook | The page as signed JSON posted to your app | A route handler, signature check, storage, revalidation | Custom sites that store content in a database or CMS |
| Deploy hook | Only a signal to rebuild | A content source the build reads | Static sites that rebuild on each change |
The Next.js deployment docs list several ways to run a site: a Node.js server, a Docker container, a static export, or an adapter for other platforms. Your hosting choice affects which path is easiest. A static export has no server to receive a webhook, so it leans on MDX files or a deploy hook.
How do I publish with MDX files?
Commit each approved page as an MDX file and let Next.js render it at build time. This keeps content in version control, so every page goes through the same review as code.
- Create a content folder, such as
content/blog, and a dynamic route that lists and reads the files. This gives every file a URL. - Render the MDX in that route and generate static params for each file. This makes each page a static page that loads fast.
- Add the exported MDX file to the folder, with its title and description in frontmatter (a short settings block at the top of the file). This is the publish step.
- Push to your Git host. Your deploy pipeline builds the site and the page goes live.
To automate step 3, have your content tool commit the file through your Git host's API or open a pull request. A pull request keeps a human check before anything ships. The tradeoff is that every page triggers a full build.
How do I publish with a signed webhook?
Add a route in your app that accepts a signed POST, verifies it, saves the content, and refreshes the affected pages. The signature proves the request came from your content tool and not from someone guessing your URL.
- Add a route handler that accepts POST requests, for example
app/api/articles/route.ts. This is the endpoint your content tool calls. - Verify the signature with the shared secret before reading the body. This rejects forged requests.
- Save the article to your database or file store. You decide where it lives and how it renders.
- Revalidate the blog index and the new page path. This makes the page appear without a rebuild.
- Return a success status. Return a success status only once the article is saved, so your sender knows whether delivery worked.
If you self-host with several server instances, plan for caching. Per the Next.js self-hosting guide, revalidateTag() only clears the cache on the instance that ran it, so other instances can serve stale content for a while. If you run more than one instance, check how your setup shares or invalidates cache across them.
How do I publish with a deploy hook?
Create a deploy hook URL at your host and call it whenever content changes. The hook starts a fresh build, and the build pulls the latest content from wherever it is stored.
- Create a deploy hook in your hosting dashboard. It gives you a URL that starts a build when called, so keep it as private as a password.
- Make your build fetch content from a CMS, API, or folder. The hook carries no content, so the build must find it.
- Call the hook from your content tool when a page is approved. This starts the build.
- Check the build log or the live page. The page is public once the build finishes.
Deploy hooks are the simplest option because there is no endpoint to secure. They also work with any CMS or backend. The cost is build time: a change is not live until the whole site rebuilds.
How we publish to Next.js at RootSmith
If you'd rather not build this plumbing, our Next.js package renders our pages in a Next.js App Router site, and approved pages publish on your own domain. We also support a signed webhook, a deploy hook, and an MDX download for any page, so the same content works with a custom backend or a repo-based workflow. The package is the quickest of the four.
In our setup, a person reviews and approves every draft unless you opt into automatic approval. With automatic approval, automations, or agent actions switched on, content can go live with no human review beforehand. Pages the package shows on your site load from our service, so export any pages you want to keep as MDX.
Our plans start at $79 a month, and every plan includes publishing. AI agents can also publish through our MCP server, which lets tools like Claude Code or Cursor run our actions.
Which path should I start with?
Start with MDX files if developers own the blog, a signed webhook if content comes from a separate system and must go live without a rebuild, and a deploy hook if your site is static and already builds from a content source. You can combine them: use a webhook for instant updates and a deploy hook as a fallback full rebuild.
See whether AI names you with our free check. It takes about two minutes, no sign-up needed.
See what AI says about you
Start free. Pick a plan when you're ready for tracking and content.