This project is already pre-configured for Netlify. The
@sveltejs/adapter-netlifyis installed and set up invite.config.ts, and anetlify.tomlis included in the repo root. You can skip the "Adapter setup" and "Createnetlify.toml" steps below and go straight to connecting the repository. Those sections are kept for reference in case you need to change the adapter or migrate the project.
Why Netlify for Decap CMS
Decap CMS can use different backends. The simplest for Git-based editing is Netlify Identity + Git Gateway. Netlify handles authentication, and Git Gateway commits to the repository on behalf of the editor—without giving them a GitHub account or write access.
Important: Git Gateway is a Netlify-specific service. It is not available on Cloudflare Pages, Vercel, or static hosts. On those platforms you must use a different backend (typically GitHub OAuth with your own auth server).
Adapter setup (already done — for reference only)
SvelteKit does not work on Netlify with adapter-auto alone if you use SSR or server endpoints. Use the official Netlify adapter:
Install the adapter:
npm i -D @sveltejs/adapter-netlifyIn your SvelteKit config (usually
vite.config.tsorsvelte.config.js), replaceadapter-auto:import adapter from '@sveltejs/adapter-netlify'; // ... adapter: adapter()Netlify will bundle your SSR routes into a Netlify Function called
render. If you want to split routes into separate functions, passsplit: true. If you want Edge Functions instead of Node-based functions, passedge: true(cannot be combined withsplit).(Optional) For a fully static site (no SSR, no server endpoints), you can use
@sveltejs/adapter-staticinstead. Output directory becomesbuild.
Create netlify.toml (already included — for reference only)
In your project root, create a netlify.toml file to tell Netlify where the build output lives:
[build]
command = "npm run build"
publish = "build"
If this file is missing, Netlify defaults to build, but creating it explicitly avoids surprises. If you set a different publish directory in the Netlify UI, you must match it here too.
Node version note: SvelteKit 3.x requires Node.js 22.17 or newer. If your Netlify build fails with
EBADENGINEfor@sveltejs/kit, addNODE_VERSION = "22.17.0"(or higher) under[build.environment]innetlify.toml, or set it in Netlify's environment variables.
Connect the repository
- Sign in to Netlify.
- Click Add new site → Import an existing project.
- Choose GitHub and authorize if asked.
- Select the repository.
- Netlify should auto-detect SvelteKit and suggest:
- Build command:
npm run build - Publish directory:
build
- Build command:
- Deploy.
Netlify installs dependencies, builds the site, and publishes it.
Enable Identity and Git Gateway
- In the Netlify site dashboard, go to Integrations → Identity → Enable Identity.
- Under Registration, set Invite only if you do not want public sign-ups. Choose Open only if you are experimenting.
- Scroll down to Services → Git Gateway → Enable Git Gateway.
Git Gateway lets Decap CMS commit to the repository without giving each editor a GitHub account or write access. It requires a repository hosted on GitHub.com or GitLab.com (self-hosted Git instances are not supported).
Custom domain note: If you use a custom domain, make sure HTTPS is working before enabling Git Gateway.
Add the Netlify Identity Widget
Decap CMS needs the Netlify Identity Widget to handle login. How you add it depends on your registration mode.
Option A: Site-wide registration (widget on main page)
Add the widget script to both your CMS entry page (/admin/index.html) and your site's main page (in SvelteKit, typically src/app.html or your root layout):
<script src="https://identity.netlify.com/v1/netlify-identity-widget.js"></script>
Then, to redirect users back to /admin/ after login, add this script before </body> on your site's main page:
<script>
if (window.netlifyIdentity) {
window.netlifyIdentity.on("init", (user) => {
if (!user) {
window.netlifyIdentity.on("login", () => {
document.location.href = "/admin/";
});
}
});
}
</script>
This is the most reliable path and works even if you change registration mode later.
Option B: Admin-only registration (invite only, no main-page widget)
If you use Invite only, you can skip the main-page widget entirely. Instead:
- Add the widget script only to
/admin/index.html. - In Netlify, go to Identity → Emails and edit the email templates. Change URLs from
{{ siteURL }}/#...to{{ siteURL }}/admin/#...so invite links land on the CMS page.
This keeps your main page lighter (no widget script) but requires editing email templates.
Invite an editor
- In Identity, click Invite users.
- Enter the editor's email.
- The editor accepts the invite and sets a password.
Open the CMS in production
After deploy, open:
https://<your-site>.netlify.app/admin/
Log in with the invited account. Decap CMS reads config.yml and connects through Git Gateway. Your config.yml should have:
backend:
name: git-gateway
branch: main
GitHub OAuth alternative (not recommended for Netlify)
If you do not want Netlify Identity, Decap CMS also supports GitHub OAuth directly. That requires an OAuth app in GitHub and a small auth server. On Netlify, Git Gateway is almost always the simpler path. Use it unless you have a specific reason not to.
Custom domain
- In Netlify, open Domain management.
- Click Add custom domain.
- Enter the domain.
- Follow the DNS instructions. Netlify provides either nameservers or a CNAME.
- Wait for DNS to propagate.
- Enable HTTPS with Let's Encrypt in Netlify.
After the domain is live, update site.json:
{
"url": "https://your-domain.com"
}
That value is used in canonical URLs and sitemap generation.
Next step
Read Deploy to Other Hosts for Vercel, Cloudflare, AWS, and cPanel. Note: Decap CMS on Cloudflare requires a GitHub OAuth backend or a custom Git Gateway implementation—Netlify Identity/Git Gateway will not work there.