Setting up Decap CMS on a Next.js site
By Yash Garg · · 5 min read
Decap CMS can be added to Next.js by placing static `admin/index.html` and `admin/config.yml` files inside the `public` folder (Decap CMS installation guide). At its core, Decap CMS is an open-source React app that acts as a wrapper for the Git workflow, using the GitHub, GitLab, or Bitbucket API (Decap CMS overview).
For developers managing client deliverables, adopting a Git-based CMS for freelancers keeps content versioned alongside your application code. This model functions differently from visual in-code editing tools like TurnIntoCMS, which allow clients to click and edit existing JSX components on a live preview without setting up administrative dashboards, content collections, or separate data schemas. Decap CMS focuses specifically on structured file authoring, storing content as clean Markdown or data files that Next.js compiles during site builds.
Step 1: Setting up public admin assets
In Next, static files are stored in `/public` (Decap CMS installation guide). The administrative dashboard for Decap CMS is completely standalone, so you will create a folder named `admin` inside `public`.
Within `public/admin/`, create an `index.html` file that loads the Decap CMS application script from a content delivery network (Decap CMS installation guide). Avoid the temptation to set up this interface inside `app/admin/page.tsx`. In the Next.js App Router, placing administrative single-page application bundles inside the application directory often causes routing collisions, bundler minification errors, and layout inheritance conflicts. Next.js is unopinionated about how you organize and colocate your project files (Next.js project structure docs).
A standard project directory structure for this integration looks like this:
| File or Folder | Purpose |
|---|---|
| `public/admin/index.html` | Entry HTML file loading the Decap CDN bundle and auth script |
| `public/admin/config.yml` | Backend settings, collections, and media configuration |
| `content/blog/` | Target directory where Decap saves Markdown posts |
| `public/images/uploads/` | Target folder for client-uploaded images |
| `app/blog/[slug]/page.tsx` | Next.js Server Component reading and displaying the content |
Step 2: Configuring collections, backends, and media paths
The administrative interface behavior is determined entirely by `public/admin/config.yml`. This file specifies the target Git branch, local development modes, media destinations, and content field definitions (Decap CMS configuration guide).
The most common point of failure when pairing Decap CMS with Next.js involves asset routing. In your YAML configuration, you can specify `media_folder`, and if `public_folder` is not set, Decap CMS defaults to the same value as `media_folder` (Decap CMS configuration guide). The `media_folder` setting indicates where files should be committed in the repository (for example, `public/images/uploads`), while `public_folder` defines the absolute path prefixed to the image URL in your frontmatter (such as `/images/uploads`). If `public_folder` is omitted or configured incorrectly, Next.js image components will look in the wrong directory and return 404 errors on live pages.
When working locally, add `local_backend: true` to your configuration and run `npx decap-server` alongside your Next.js local development server. This proxy allows you to create, edit, and delete files on your local drive without pushing mock commits to your remote Git branches. This structured schema approach mirrors other Git-backed setups, such as TinaCMS, which also relies on defining explicit collections for data types (TinaCMS docs). For teams evaluating ways to let clients edit Next.js sites, this configuration establishes strict boundaries around what content fields an editor can manipulate.
Step 3: Handling authentication on Netlify versus Vercel
Authentication requirements vary depending on where the Next.js site is hosted. If the website is deployed to Netlify, identity management is straightforward using Netlify Identity and Git Gateway (Decap CMS Next.js docs). You enable Netlify Identity in the hosting settings, turn on Git Gateway, and include the Netlify Identity widget script inside both `public/admin/index.html` and your root HTML layout.
When deploying to Vercel, Cloudflare Pages, or AWS, Git Gateway is unavailable. In Pages, the Decap CMS configuration specifies `backend: name: github` along with `base_url: https://pages.cloud.gov` and `auth_endpoint: external/auth/github` (cloud.gov Decap documentation). This bridge can be an open-source OAuth proxy or a custom Next.js API route that exchanges GitHub authorization codes for access tokens.
Managing permissions properly is vital for client handoffs. You can grant access through GitHub Apps, which provide narrow, repository-specific permissions (GitHub Apps documentation). This is preferable to executing a repository transfer, which hands over full administrative rights to the receiving account immediately (GitHub repository transfer docs).
Ensure you also include a post-login redirect callback script in your administrative HTML file. Without this script, non-technical clients who click confirmation links in their email invites can become trapped on a blank dashboard rather than landing in the editing interface.
Step 4: Reading and rendering markdown in Next.js Server Components
It writes raw text files containing frontmatter directly into your repository. Your Next.js application remains responsible for fetching and parsing these files at build time or request time.
In the Next.js App Router, content parsing is handled cleanly inside Server Components. To keep your application organized, place parsing functions and file system readers inside private, non-routable folders such as `app/blog/_lib/data.ts` (Next.js project structure docs).
If your editorial content relies strictly on plain typography, standard Markdown converted with parsing tools is sufficient. MDX allows you to write JSX directly in your markdown files, providing a way to add dynamic interactivity and embed React components within your content (Next.js MDX guide). For deep architectural comparisons between these formats, review our guide on MDX content for Next.js client sites.
Workflow trade-offs and client handoff checks
With Decap CMS, content editors can make commits to your site repository without touching code or learning Git (Decap CMS overview). In a continuous integration and deployment environment, that commit initiates a full static rebuild on your host. Non-technical clients accustomed to traditional database systems often find it jarring that edits take 1 to 3 minutes to reflect on live URLs. Setting expectations regarding build pipelines is a crucial part of client onboarding.
Before delivering the site to your client, perform these essential handoff checks:
- Test asset resolution by uploading an image in the CMS and verifying it renders through the Next.js image component on production.
- Confirm that the production build pipeline triggers cleanly on content commits without deployment timeouts.
- Establish repository rules to protect the main branch on client sites, routing client publications through staging branches or pull requests if the client tends to alter global settings.
- Verify that invited users can log in, reset passwords, and publish without developer intervention.
If configuring YAML schemas, setting up OAuth proxies, and teaching clients about Git commit delays feels too heavy for a specific build, consider visual tools like TurnIntoCMS. TurnIntoCMS connects to an existing GitHub repository and lets clients edit content in place on a live preview without schema definitions. It is free for one project and costs $1 USD as a one-time payment per additional project, committing updates directly to JSX or data files while bypassing CMS setup complexity.
FAQ
Does Decap CMS work with the Next.js App Router and Server Components?
It commits Markdown and media files to your repository, allowing Next.js Server Components to read and render those files using standard Node.js file system methods.
Can you run Decap CMS on a Next.js site hosted on Vercel?
Instead, you must configure the backend to use GitHub directly and establish an external OAuth proxy to handle client authentication securely.
Why are uploaded images returning 404 errors on Next.js pages?
`media_folder` specifies where uploaded files are saved in the repo, while `public_folder` indicates where they are found in the published site (Decap CMS configuration guide). To work properly with Next.js static asset routing, save images to `public/images/uploads` while setting the public web path prefix to `/images/uploads`.
Is Decap CMS suitable for large websites with many editors?
Decap CMS is generally unsuitable for large editorial teams publishing dozens of articles concurrently. Because every update produces a Git commit, high-volume publishing environments frequently suffer from merge conflicts, prolonged continuous integration deployment queues, and repository bloat from binary uploads.
Sources
- 1. Install Decap CMS (decapcms.org, checked December 4, 2026)
- Getting started with Decap CMS (docs.cloud.gov, checked December 4, 2026)
- NextJS | Decap CMS | Open-Source Content Management System (decapcms.org, checked December 4, 2026)
- 3. Configure Decap CMS (decapcms.org, checked December 4, 2026)
- Decap CMS overview (decapcms.org, checked December 4, 2026)
- Get Started and learn about TinaCMS (tina.io, checked December 4, 2026)
- Project structure and organization (nextjs.org, checked December 4, 2026)
- How to use markdown and MDX in Next.js (nextjs.org, checked December 4, 2026)
- Transferring a repository (docs.github.com, checked December 4, 2026)
- About creating GitHub Apps (docs.github.com, checked December 4, 2026)