Agent-Ready Sanity + Next.js Kit | The Content Architecture
The agent-ready Sanity and Next.js kit. Six years of decisions committed: page builder, fetch layer, AGENTS.md, skills, MCP servers, llms.txt. Buy once, own it forever.
https://www.contentarchitecture.dev/Reader - page text saved at the timeBUILT FOR AGENTIC DEVELOPMENT.
The Sanity setup
agents don't reinvent.
Every run invents a new one, none decided. This Next.js and Sanity kit commits six years of decisions. Your agent
builds inside them, and checks its work through MCP and a real Chrome.
FOR ENGINEERS WHO WORK IN NEXT.JS AND SANITY.
GET
ACCESS
NEXT 16.X SANITY V6 TS: STRICT. AGENTS.MD: LOADED MCP: 2 SERVERS DRIFT: 0
NEXT 16.X
SANITY V6
TS: STRICT
AGENTS.MD: LOADED
MCP: 2 SERVERS
DRIFT: 0
CLICK & HOLD
COMMON PROBLEMS
001 Agent redesigns the architecture on every prompt ∞ HRS. 002 Page builder schema + section registration + preview ~5 HRS. 003 Draft mode + live preview + webhook revalidation ~4 HRS. 004 CDN vs. data cache — stale content after publish ~3 HRS. 005 Studio structure editors can actually use ~3 HRS. 006 SEO metadata, OG images, sitemaps, robots.txt ~2 HRS. 007 Rewriting the same 12 components ~2 HRS. 008 Redirects, analytics, view transitions, Mux ~2 HRS. 009 Contact form + spam guard + Resend wiring ~1 HR. 010 ESLint, Prettier, Biome, git hooks ~1 HR. 011 Basic auth for staging environments ~1 HR. ESTIMATED TIME LOST: ~24 HOURS PER PROJECT (3 FULL DAYS)
∞ HRS
~5 HRS
~4 HRS
~3 HRS
~3 HRS
~2 HRS
~2 HRS
~2 HRS
~1 HR
~1 HR
~1 HR
The page builder alone costs
you days. Every single time.
It's never the easy stuff that hurts. It's the page builder, modeled from scratch again. Draft mode and live preview, wired up and subtly broken
again. The cache bug where published content goes stale and the client swears you shipped something wrong. A Studio structure your editors
actually understand, instead of one they email you about.
This is the part nobody quotes for and everybody rebuilds. Days gone before the real work starts.
Every decision already made. So
you can skip to the actual work.
The Content Architecture is the production foundation underneath my client work. Hundreds of choices, schema,
fetching, structure, SEO, made once over six years and committed. Not a starter you outgrow in a month. Clone it,
rename it, ship. The architecture is fixed; the tools are defaults you can swap. Fixed decisions are also what make
agentic development work: an agent inside committed conventions ships, an agent without them redesigns.
001 / AGENT-NATIVE
AGENTS.md and a dozen scoped skills let Claude Code or Cursor
ingest the conventions before the first prompt, instead of
proposing a plausible new architecture per run. Two preconfigured
MCP servers ship in the repo: one reads the Next.js runtime,
compilation errors, routes, docs matching the installed version, the
other drives a real Chrome for screenshots, traces, and
screencasts. The agent builds inside the decisions and checks its
own work.
002 / AGENT-READY IN PRODUCTION
The shipped site stays legible to agents that read it. An editable
llms.txt, drafted from your content with Sanity Agent Actions, and a
token-light Markdown version of every page, served on the same
URL through content negotiation. Generated in Studio, served
verbatim, and a feature you can put in your own proposal.
003 / SCHEMA AS A SYSTEM
Document roles, factory functions, singletons. Every schema looks
the same, so every editor knows where to go. You never model the
structure from scratch again.
004 / THE HARD FIELDS, ALREADY BUILT
The three fields nobody gets right the first time. A link field that
handles internal refs, external URLs, email, and params. A media
field that normalizes image, Mux, Rive, and Lottie into one shape,
each returning dimensions, so you forget layout shift. A page
builder with guardrails. Reusable, typed, composed everywhere.
005 / FETCH LAYER, SOLVED
CDN bypassed in production, Data Cache doing the work,
webhooks invalidating on publish, draft mode wired in. Stale
content after publish stops being a midnight problem.
006 / A STUDIO EDITORS ACTUALLY USE
Every document type where editors expect it. Pages own their
routes, singletons stay locked, no hunting. Clients stop emailing to
ask where their homepage lives.
007 / SEO, DONE NOT DEFERRED
Per-page metadata from schema, sitemap driven by Sanity,
OpenGraph with auto-cropped images, robots.txt included. Nothing
bolted on the week before launch.
008 / PRODUCTION-READY FROM DAY ONE
Basic auth, spam-protected forms, redirects managed in Sanity,
analytics, view transitions. The plumbing you reconfigure every
project, already wired.
009 / WIRED UP, NOT JUST CLONED
An interactive setup script provisions the Sanity project, mints the
tokens, adds CORS, and registers the revalidation webhook, then
writes your .env. Export and migration scripts back up production
and move content between environments. The first run is handled,
not documented.
NEXT.JS
ASTRO
THIS IS THE ACTUAL REPO.
Ctrl J
Ctrl K
.AGENTS
.HUSKY
APP
COMPONENTS
DOCS
FEATURES
SANITY
SCRIPTS
SEED
TEMPLATES
.ENV.EXAMPLE
.GITIGNORE
.MCP.JSON
.NPMRC
.NVMRC
AGENTS.MD
ASSETS.D.TS
BIOME.JSONC
CLAUDE.MD
ENV.TS
GETTING-STARTED.MD
LEFTHOOK.YML
NEXT-ENV.D.TS
NEXT.CONFIG.TS
PACKAGE.JSON
PACKAGE-LOCK.JSON
PLOPFILE.MJS
PROXY.TS
README.MD
GET-ACCESS.MD
SANITY-SCHEMA.JSON
SANITY.CLI.TS
SANITY.CONFIG.TS
SKILLS-LOCK.JSON
TSCONFIG.JSON
README.MD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# The Content Architecture
A modern Next.js 16 starter with Sanity CMS integration.
## Features
- Next.js 16 with App Router and Server Components
- Sanity CMS with in-app Studio
- TypeScript 6, Tailwind CSS 4, and Biome
- Reusable components, page builder sections, and rich text blocks
- Draft mode with Sanity Live, SEO helpers, and ISR revalidation
- **HTTP Basic Auth (optional):** `proxy.ts` gates the site or individual URLs using
`BASIC_AUTH_*` environment variables and CMS toggles (Site -> Security, per-entry
"Password protect"). See [`docs/features/basic-auth.md`](docs/features/basic-auth.md).
- **llms.txt for AI assistants:** an editable, AI-generated `/llms.txt` (per llmstxt.org),
drafted from your content with Sanity Agent Actions from the Site document's Agents tab.
See [`docs/features/llms-txt.md`](docs/features/llms-txt.md).
- **Agent Markdown (content negotiation):** pages and articles serve a token-light Markdown version
to agents that send `Accept: text/markdown`, on the same URL. Generated and stored per page from
the Agents tab, then served verbatim. See [`docs/features/agent-markdown.md`](docs/features/agent-markdown.md).
- Feature modules for redirects, Umami analytics, view transitions, Mux and
native video, and spam prevention
- Scaffolding via Plop for repeatable section/block generation
- Seed dataset of example content (pages, articles, media), imported with `npm run sanity:dataset-import`
- [`@mantine/hooks`](https://mantine.dev/hooks/getting-started/) for shared React hooks;
`features/dom/use-breakpoint.ts` wraps `useMediaQuery` for Tailwind-aligned
breakpoints and touch detection
## Getting Started
**New here? Start with [`GETTING-STARTED.md`](GETTING-STARTED.md).** It is the guided, top to bottom path
from a fresh clone to your first rendered section. The sections below are the reference.
### Prerequisites
- Node.js >= 24.15.0
- npm >= 11.6.2
### Installation
```bash
npm install
```
### Environment Variables
Create a `.env` file and add at least:
```env
SANITY_API_VIEW_TOKEN=your-view-token
SANITY_API_EDIT_TOKEN=your-edit-token
# Optional: only needed if you register the Sanity publish webhook
SANITY_REVALIDATE_SECRET=your-revalidate-secret
RESEND_API_KEY=your-resend-api-key
RESEND_EMAIL_FROM=notifications@your-domain.com
NEXT_PUBLIC_URL=http://localhost:3000
NEXT_PUBLIC_SANITY_DATASET=production
NEXT_PUBLIC_SANITY_PROJECT_ID=your-project-id
NEXT_PUBLIC_SANITY_API_VERSION=2025-02-19
NEXT_PUBLIC_SANITY_STUDIO_BASE_PATH=/studio
```
`NEXT_PUBLIC_SANITY_STUDIO_BASE_PATH` is the public URL for Studio. The app mounts
Studio under `app/sanity-studio/`; `next.config.ts` rewrites the public path to that
folder. See [`docs/sanity/studio-and-structure.md`](docs/sanity/studio-and-structure.md).
### HTTP Basic Auth (optional)
For staging or client-review gates, set `BASIC_AUTH_USERNAME` and `BASIC_AUTH_PASSWORD`
in the same environment as the app. Turn protection on in Sanity (site-wide and/or
per document with "Password protect"); credentials are not stored in the CMS. Full
behavior: [`docs/features/basic-auth.md`](docs/features/basic-auth.md).
### Development
```bash
npm run dev
```
- App: [http://localhost:3000](http://localhost:3000)
- Studio: `http://localhost:3000` + your `NEXT_PUBLIC_SANITY_STUDIO_BASE_PATH`
### Build
```bash
npm run build
npm run start
```
## Docs
Feature-level docs live in `docs/` so the root README stays lightweight.
- Documentation hub: [`docs/README.md`](docs/README.md)
- HTTP Basic Auth (env + CMS toggles, `proxy.ts`): [`docs/features/basic-auth.md`](docs/features/basic-auth.md)
- Redirects: [`docs/features/redirects.md`](docs/features/redirects.md)
- Code generation (Plop): [`docs/features/code-generation.md`](docs/features/code-generation.md)
- Spam prevention: [`docs/features/spam-prevention.md`](docs/features/spam-prevention.md)
- Umami tracking: [`docs/features/umami-tracking.md`](docs/features/umami-tracking.md)
- View transitions: [`docs/features/view-transitions.md`](docs/features/view-transitions.md)
- Git hooks: [`docs/features/git-hooks.md`](docs/features/git-hooks.md)
- Agent skills: [`docs/features/agent-skills.md`](docs/features/agent-skills.md)
- Dataset export and migration: [`docs/sanity/dataset-migration.md`](docs/sanity/dataset-migration.md)
- Sanity project setup: [`docs/sanity/project-setup.md`](docs/sanity/project-setup.md)
## Scripts
- `npm run dev`: Start development server
- `npm run build`: Build for production
- `npm run start`: Start production server
- `npm run check.types`: TypeScript type checking
- `npm run check`: Run all checks
- `npm run format`: Format with Biome
- `npm run sanity:typegen`: Generate Sanity types
- `npm run plop`: Scaffold new sections and rich text blocks
- `npm run sanity:cli`: Run the Sanity CLI with `.env` loaded (via dotenvx)
- `npm run sanity:dataset-export`: Backup a dataset to `./backups/`
- `npm run sanity:dataset-import`: Import a dataset backup or the bundled seed content
- `npm run sanity:dataset-migrate`: Copy one dataset into another with confirmations
- `npm run sanity:project-setup`: Wizard for project, tokens, CORS, webhook, and `.env`
## Project Structure
```text
.
|-- app/ # Next.js App Router
|-- components/ # Shared React components
|-- features/ # Feature modules
|-- public/ # Static assets
|-- sanity/ # Sanity config, schema, structure
|-- scripts/ # Dataset and project-setup CLIs
|-- seed/ # Bundled starter content (dataset export)
|-- docs/ # Project documentation
|-- proxy.ts # Next.js Proxy (Basic Auth: env + CMS toggles)
|-- next.config.ts # Next.js config and rewrites
+-- env.ts # Typed environment config
```
## Agent Skills
AI guidance for this repository lives in `AGENTS.md` and `.agents/skills/`.
## License
MIT
TERMINAL
~/the-content-architecture-next-js > get-access # €549 · one-time
~/the-content-architecture-next-js >
⎇
MAIN
UPDATED TODAY
97 COMMITS
The work that gets remembered.
Real sites, shipped on The Content Architecture. With the plumbing
already handled, the effort goes where it shows. The work here has been
recognized by Awwwards, FWA, and CSSDA, and picked up across
design directories.
GOOD FELLA
HOUSE OF HONEY
ASPEN SEARCH
ANUC HOME
EDOARDO LUNARDI
SERVE ROBOTICS
MURALIA
BLINK
WASL
CREATIVE LIVES IN PROGRESS
THIS SITE :D
“We shipped the Good Fella site on an early version and it saved us tons of time. Six months in, we're still building pages and sections in an afternoon without fighting the setup.”
“We shipped the Good Fella site on an early version and it saved us tons of time. Six months in, we're still building pages and sections in an afternoon without fighting the setup.”
JULIAN FELLA
CO-FOUNDER, GOOD FELLA
“Edo and I ran a client project on this together. The plumbing was already handled, so the week we'd normally lose to setup went into the creative work the client actually remembers.”
“Edo and I ran a client project on this together. The plumbing was already handled, so the week we'd normally lose to setup went into the creative work the client actually remembers.”
ELLIOTT MANGHAM
FOUNDER & FRONTEND ENGINEER
“I opened the fetch layer and found the revalidation problem I'd burned two days on last project, already solved and committed. That one folder paid for the whole thing, and the rest is six years of decisions I'd have made the slow way.”
“I opened the fetch layer and found the revalidation problem I'd burned two days on last project, already solved and committed. That one folder paid for the whole thing, and the rest is six years of decisions I'd have made the slow way.”
MALIK KOTB
WEB DESIGNER & ENGINEER
[<]
01
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
/03
[>]
Slide 1 of 3
Two editions.
One architecture.
Lifetime updates.
ASTRO AND BUNDLE PRICING
ANNOUNCED AT LAUNCH.
NEXT.JS
€549
€
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
001
THE NEXT.JS 16 + SANITY V6 REPO
002
FOR NEXT.JS + SANITY ENGINEERS, NOT NO-CODE
GET
ACCESS
ASTRO
Soon
001
THE ASTRO 7 + SANITY V6 REPO
002
FOR ASTRO + SANITY ENGINEERS, NOT NO-CODE
IN DEVELOPMENT
Email
NOTIFY
ME
NEXT.JS + ASTRO
Soon
001
BOTH REPOS, NEXT.JS AND ASTRO
002
FOR NEXT.JS + ASTRO ENGINEERS, NOT NO-CODE
IN DEVELOPMENT
Email
NOTIFY
ME
EVERY EDITION INCLUDES
001
ONE-TIME FEE, NO SUBSCRIPTION
002
PERPETUAL LICENSE, UNLIMITED PROJECTS
003
COMMERCIAL USE, NO ATTRIBUTION
004
LIFETIME UPDATES, INCLUDED
005
AGENT-READY: SKILLS, MCP, LLMS.TXT
006
PRIVATE GITHUB DISCUSSIONS
007
DIRECT LINE TO THE MAINTAINER
008
FULL SOURCE ON PURCHASE, SALES FINAL
009
ALL PRICES IN EUR
Before you buy
GET
ACCESS
Q.001 / WHAT STACK IS THIS BUILT ON?
Next.js 16 with the App Router and React Compiler, Sanity v6, TypeScript in strict mode, Tailwind 4, and Biome for lint and format. Deploys on Vercel out of the box, and runs on Cloudflare via OpenNext.
Q.002 / DOES IT WORK WITH CLAUDE CODE AND CURSOR?
It is built for it. AGENTS.md plus a dozen scoped skills mean any agentic tool ingests the conventions and boundaries before you write a prompt. Ask an agent to build this from scratch and you get a different architecture every run. Here the decisions are already made, so the agent works inside them instead of inventing new ones. You still read and write the real code yourself; the agent works inside the architecture, it does not write the app for you.
It also ships two preconfigured MCP servers. One reads the running Next.js dev server: compilation errors, routes, docs that match the installed version. The other drives a real Chrome: screenshots across viewports, performance traces, screencasts of transitions it can review frame by frame. The agent doesn't just know the conventions, it can look at the app it's changing.
Q.003 / IS THE SHIPPED SITE AGENT-READY TOO?
Yes. Every site built on this ships with an editable llms.txt, drafted from your content with Sanity Agent Actions from the Site document, and a token-light Markdown version of every page and article, served on the same URL to any agent that sends Accept: text/markdown. You generate it per page in Studio, review it, and it is served verbatim. Your client's site is readable by assistants and agentic crawlers on day one, a line item you can put in your own proposal.
Q.004 / AM I LOCKED INTO THIS EXACT STACK?
No. The opinion lives in the architecture, and the tools sit on top of it. Tailwind, Biome, Mux, Rive, Lottie, these are the defaults I reach for on most projects, wired in cleanly so they come out just as cleanly. Don't want Tailwind? Pull it. Prefer ESLint over Biome? Swap it. No Mux, Rive, or Lottie in this project? Drop them. What you are really buying is the patterns underneath, how content is modeled, fetched, and composed. The libraries are just what I ship with on 90% of my projects.
The Sanity layer is decoupled by design too. Every import inside the sanity/ folder is relative or an external package, nothing reaches into the Next.js app, so you can lift the whole Studio, schema, and field primitives into another project. The content layer doesn't hold you hostage to the front end.
Q.005 / DO I NEED TO KNOW SANITY?
Some, yes. This is a real codebase, not a no-code template. You should be comfortable in a Sanity schema file and a Next.js project. If you are, you will feel at home in minutes. If you have never opened a schema, the article series is the best place to start before deciding.
Q.006 / IS THIS FOR ME IF I DON'T CODE?
No, and I'd rather tell you here than take your money. This is a real Next.js and Sanity codebase, not a no-code tool: no visual page builder, no drag-and-drop editor. You clone the repo and write real code on top of it. If you don't work in Next.js and Sanity, it isn't for you.
Q.007 / CAN I USE THIS FOR CLIENT WORK?
Yes. Unlimited projects, commercial use, no attribution required. Use it on every client site you ship. The one thing you cannot do is resell the architecture itself as a competing product.
Q.008 / HOW IS THIS DIFFERENT FROM OTHER BOILERPLATES?
Most boilerplates give you a pile of features. This gives you decisions. Every hard call, document modeling, the fetch layer, revalidation, the link and media fields, was made once over six years and committed. It is opinionated on purpose, and it is the architecture I ship my own client work on, not a side project cleaned up for sale.
Q.009 / WHY NOT JUST USE A FREE SANITY STARTER?
A free starter gets you a clean install and the easy parts. What it leaves you is the work that actually costs the days: a page builder with guardrails, the fetch layer and revalidation, the link and media fields, a Studio structure your editors don't email you about. Those decisions are still yours to make on every project. Here they're already made, over six years of real client work, and committed. You're not paying for code you could scaffold in an afternoon. You're paying to skip the part nobody quotes for.
Q.010 / WILL IT BREAK ON NEXT.JS UPDATES?
This is my daily driver, so I keep it current. Next.js majors, Sanity migrations, breaking plugin changes, I handle them and push the update. Your license includes every update for as long as I maintain it, which is for as long as I am using it myself.
Q.011 / WHAT DO I ACTUALLY GET, AND FOR HOW LONG?
The full repo on day one, a perpetual license, and lifetime updates included, not sold as a separate tier. One payment, no subscription. You own it forever.
Q.012 / DO YOU OFFER SUPPORT?
Buyers get a private GitHub Discussions space, threaded and searchable, where I answer questions directly. For anything bigger, I am reachable by email. What you will not find is a Discord to get lost in or a support queue that routes you to a bot.
Q.013 / WHAT IF I FIND A BUG?
Tell me, and it gets fixed in the codebase, usually fast. A bug you hit is a bug my own client projects will hit too, so fixing it is in my interest as much as yours. The patch ships to everyone.
Q.014 / CAN I GET A REFUND?
Because you get the full source on purchase, sales are final, the same way every serious code product works. Once the repo is cloned, it cannot be un-cloned. So I have put everything you need to decide up front: read the article series for the full reasoning, browse the real repo above, and look at the sites already shipped on it. If something is unclear before you buy, email me and I will answer honestly, sometimes that means telling you it is not the right fit.
Q.015 / WHAT IS THIS NOT?
It is a set of architectural decisions, made once over six years and committed, that gets you to the real work faster. You write real code on top of it. There is no no-code editor, no UI kit or component library to theme, no auth-billing-dashboard SaaS scaffolding, and no course wrapped around it, though the article series explains the reasoning behind it. You buy it once and own it.
THE CONTENT ARCHITECTURE
/$$$$$$$$ /$$ /$$ /$$$$$$ /$$
|__ $$__/| $$ | $$ /$$__ $$ | $$
| $$ | $$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ |__/ \ $$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$$
| $$ | $$__ $$ /$$__ $$ | $$__ $$ /$$__ $$| $$ /$$/|_ $$_/ /$$$$$/ /$$__ $$ |____ $$| $$ | $$ /$$_____/
| $$ | $$ \ $$| $$$$$$$$ | $$ \ $$| $$$$$$$$ \ $$$$/ | $$ |___ $$ | $$ | $$ /$$$$$$$| $$ | $$| $$$$$$
| $$ | $$ | $$| $$_____/ | $$ | $$| $$_____/ >$$ $$ | $$ /$$ /$$ \ $$ | $$ | $$ /$$__ $$| $$ | $$ \____ $$
| $$ | $$ | $$| $$$$$$$ | $$ | $$| $$$$$$$ /$$/\ $$ | $$$$/ | $$$$$$/ | $$$$$$$| $$$$$$$| $$$$$$$ /$$$$$$$/
|__/ |__/ |__/ \_______/ |__/ |__/ \_______/|__/ \__/ \___/ \______/ \_______/ \_______/ \____ $$|_______/
/$$ | $$
| $$$$$$/
\______/
/$$$$$$ /$$$$$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$ /$$ /$$$$$$ /$$$$$$$
|____ $$ /$$__ $$ /$$__ $$ | $$ | $$ /$$__ $$| $$ | $$ /$$__ $$ /$$_____/
/$$$$$$$| $$ \__/| $$$$$$$$ | $$ | $$| $$ \ $$| $$ | $$| $$ \__/| $$$$$$
/$$__ $$| $$ | $$_____/ | $$ | $$| $$ | $$| $$ | $$| $$ \____ $$
| $$$$$$$| $$ | $$$$$$$ | $$$$$$$| $$$$$$/| $$$$$$/| $$ /$$$$$$$//$$
\_______/|__/ \_______/ \____ $$ \______/ \______/ |__/ |_______/|__/
/$$ | $$
| $$$$$$/
\______/
LEARN MORE
+