Add a route to your client’s site that serves /sitemap.xml from Atomicity. The route fetches the XML on the server and returns it from the client’s own domain, so search engines never see an Atomicity address.
Before you start, you need:
- The site’s primary domain set in its site settings.
- A site that runs code on the server or on Cloudflare. A fully static build can’t proxy; in Astro, that means on-demand rendering with an adapter.
Only your agency team can see the Install tab.
Add the route
- Open the site, go to Sitemap, then Install.
- Under Add the route to your site, pick your framework. The snippet has the site’s Atomicity address filled in.
- Copy each file into the site, at the path shown on its tab.
- Deploy the site.
| Framework | Files |
|---|---|
| TanStack Start | A shared helper, app/routes/sitemap[.]xml.ts, and app/routes/sitemaps.$file.ts |
| Astro | A shared helper, src/pages/sitemap.xml.ts, and src/pages/sitemaps/[file].ts |
| Remix | A shared helper, app/routes/sitemap[.]xml.ts, and app/routes/sitemaps.$file.ts |
| React Router 7 (framework mode) | A shared helper, app/routes/sitemap.ts, app/routes/sitemap-file.ts, and two entries in app/routes.ts |
| Next.js (App Router) | lib/atomicity-sitemap.ts, app/sitemap.xml/route.ts, and app/sitemaps/[file]/route.ts |
| Cloudflare Worker | One file. Add routes for your-domain.com/sitemap.xml and your-domain.com/sitemaps/*. Works for any site on Cloudflare. |
For example, the Next.js route that serves /sitemap.xml is:
import { atomicitySitemap } from "@/lib/atomicity-sitemap";
export const dynamic = "force-dynamic";
export const GET = () => atomicitySitemap("/sitemap.xml");What the route does
Every snippet behaves the same way:
- Serves two kinds of path:
/sitemap.xml, and child files under/sitemaps/, which a sitemap over 50,000 URLs is split into. Anything else gets404. - Fetches from Atomicity at
https://app.atomicity.dev/s/YOUR_SITE_ID/, with a 5-second timeout. - Passes caching through: Atomicity’s
Cache-Controlheader, which lets browsers and CDNs keep the sitemap for 5 minutes, so edits show up within a few minutes. - Keeps a copy: the helper keeps each file in memory for a minute, and on Cloudflare Workers at the edge for 5 minutes, so most requests never reach Atomicity.
- Falls back: if Atomicity can’t be reached, it serves the last good copy it has. With no copy, it answers
503withRetry-After: 60. - Answers not found when Atomicity does: if the sitemap is turned off or the site’s key is revoked.
Add the sitemap to robots.txt
Under Add it to robots.txt, copy the line for the site and add it to its robots.txt:
Sitemap: https://yourclient.com/sitemap.xmlSubmit the same address in Google Search Console and Bing Webmaster Tools.
Check it’s serving
Under Check it, select Check again. Atomicity fetches the site’s /sitemap.xml and shows one of:
| Result | Meaning |
|---|---|
| Serving | The site is returning this sitemap. |
| Reachable, but not this sitemap yet | A cached copy can take a few minutes to catch up. If it doesn’t, the site may still be serving an old file, or the route isn’t deployed. |
| That address isn’t a sitemap | Check that the route is deployed. |
| Nothing came back | Deploy the route, then check again. |
| This site has no domain yet | Add the domain in site settings, then check. |
