What is your developer-dependent CMS actually costing you? Calculate your costs and get a full report
What is your developer-dependent CMS actually costing you? Calculate your costs and get a full report
Fully Featured Starter
The Advanced Next.js Demo Site is a complete marketing site built on Agility CMS with Next.js 16, React 19 and TypeScript. Where the basic starter shows the essentials, the demo shows what a full site looks like: personalization, A/B testing, multiple locales, AI search, analytics and an MCP server, all driven by content in Agility.
The brand on the site, Galaxy Tech, and its prices are fictional.
| Feature | How it works | Read more |
|---|---|---|
| Audience and region personalization | ?audience= and ?region= pick hero content, customer logos and pricing tiers, while pages stay prerendered | Audience and Region Personalization with Next.js |
| A/B testing | An A/B Test Hero swaps in a PostHog feature-flag variant | A/B/n Testing in Agility CMS |
| Analytics | A small analytics layer tags every event with the Agility page and content IDs, and loads PostHog after the page is idle | A Provider-Agnostic Analytics Layer with PostHog in Next.js |
| Multiple locales | The default locale has no URL prefix, other locales do, and the language switcher lands on the same page | Multi-Locale Support with Next.js |
| AI search and chat | Azure OpenAI or OpenAI with an Algolia search tool, configured from a content item | AI Search, Clean Markdown and an MCP Server in a Next.js Site |
| Content for AI agents | A Markdown copy of every page (add .md to the URL), /llms.txt, and an MCP server at /api/mcp | AI Search, Clean Markdown and an MCP Server in a Next.js Site |
| Page transitions | A blog card's image morphs into the post's hero image with React's ViewTransition | Shared-Element Page Transitions with React ViewTransition |
| Caching | Cache Components ("use cache"), with cache tags cleared by the publish webhook | Caching with Next.js and Agility |
| Responsive images | AgilityPic with per-breakpoint sources and focal-point crops | Using the AgilityPic Component for Responsive Images |
cacheComponents: true) and React 19.3@agility/nextjs 16 and @agility/content-fetch 2The demo's Agility instance has 24 content models and 20 components, plus the built-in Rich Text Area. Most content models and every component carry guidance in the CMS that says when to use them.
| Group | Models |
|---|---|
| Blog | Post, Author, Category, Tag |
| Personalization and testing | Audience, Region, Customer Profile, Personalized Hero Item, A/B Test Hero Item |
| Component content | Bento Card, Carousel Slide, FAQ Item, Logo Item, Pricing Tier, Stat, Testimonial Item |
| Site header and footer | Header, Top Level Nav, Nav Link, Footer, Footer Link, Footer Social Link |
| Settings | Global Settings, AI Search Configuration |
| Component | Content it reads |
|---|---|
| Hero, Background Hero, Header | Its own fields |
| Personalized Background Hero | Personalized Hero Items, one per Audience, falling back field by field to its own content |
| A/B Test Hero | A/B Test Hero Items, one per PostHog variant |
| Bento Section | Bento Cards |
| Carousel | Carousel Slides |
| Company Stats, Stats Strip | Stats |
| Logo Strip | Logo Items |
| Personalized Logo Strip | Customer Profiles, filtered by Audience |
| Testimonial, Testimonials | Testimonial Items |
| Team Listing | Authors |
| Pricing Cards | Pricing Tiers, optionally per Region |
| Pricing Table | A JSON field of plans and features |
| Frequently Asked Questions | FAQ Items |
| Post Listing, Post Details | Posts, each with an Author, a Category and Tags. Post Details runs on the dynamic post page |
| Contact Us | Its own fields. The form posts to /api/contact, which only validates and logs: point it at your own endpoint |
| Rich Text Area | Its own HTML field |
The header and footer aren't components on pages. The layout reads the first Header and Footer items and renders them on every page.
The sitemap has Home, About Us, Pricing, Features, Contact Us and Blog. Blog has a dynamic child page that renders one Post per URL (/blog/{slug}). Each page is a set of the components above in its main content zone.
| Path | What's there |
|---|---|
src/proxy.ts | Preview mode, redirects, locale routing, the .md rewrite, query-string handling, 404s for unpublished paths and cache headers |
src/app/[locale]/[...slug]/page.tsx | The one page route for every CMS page |
src/components/agility-components/ | One React component per Agility component, registered in index.ts |
src/lib/cms/ | Cached data access: getContentItem, getContentList, getSitemapFlat and the rest |
src/lib/cms-content/ | Composed reads: header, footer, settings, audiences, regions, AI configuration, metadata |
src/lib/i18n/ | Locale configuration and URL helpers |
src/lib/analytics/, src/components/analytics/ | The analytics layer |
src/lib/ai/, src/app/api/ai/ | AI search and the chat agent |
src/app/api/ | Route handlers: preview, revalidate, search, MCP, Markdown, locale switching, contact |
Every Agility component maps to a React component by name in src/components/agility-components/index.ts. Name matching is case-insensitive:
const allModules = [
{ name: "BentoSection", module: BentoSection },
{ name: "PersonalizedBackgroundHero", module: PersonalizedBackgroundHero },
// ...
]
The SDK still calls components "modules" in code (allModules, module.contentid).
Content reads are cached with Cache Components: each getter is a "use cache" function with cacheLife("days") and a cache tag such as agility-content-{contentID}-{locale}, agility-content-{referenceName}-{locale} or agility-page-{pageID}-{locale}. When content is published, Agility calls the /api/revalidate webhook, which clears the matching tags, so changes show without a rebuild. See Caching with Next.js and Agility.
Turn on Enable secure delivery on the webhook in Agility and verify its signature in the route, so only Agility can clear your caches. Indexing Agility Content for Search shows how.
git clone https://github.com/agility/nextjs-demo-site-2026.git
cd nextjs-demo-site-2026
npm install
Create .env.local in the project root with the variables below, then start the dev server:
npm run dev
npm run build runs the prebuild script first (npm runs it automatically). It rebuilds the redirect cache from the URL redirections in Agility.
| Variable | Needed for |
|---|---|
AGILITY_GUID | Your instance GUID |
AGILITY_API_FETCH_KEY, AGILITY_API_PREVIEW_KEY | Published and preview content |
AGILITY_SECURITY_KEY | Validating preview requests from Agility (not webhooks) |
AGILITY_LOCALES | Comma-separated locale codes. The first is the default, served without a prefix |
AGILITY_SITEMAP | The sitemap channel name |
SITE_URL | Absolute URLs in the sitemap, llms.txt, the MCP server and metadata |
NEXT_PUBLIC_POSTHOG_KEY, NEXT_PUBLIC_POSTHOG_HOST | Analytics and A/B testing (optional; without them PostHog doesn't load) |
ALGOLIA_APP_ID, ALGOLIA_SEARCH_API_KEY | Search and the AI search tool (optional) |
AZURE_AI_RESOURCE, AZURE_AI_KEY, AZURE_AI_DEPLOYMENT | AI search with Azure OpenAI (optional) |
OPENAI_API_KEY, OPENAI_API_MODEL | AI search with OpenAI, used when the Azure variables aren't set (optional) |
BUILD_HOOK_URL | A build hook to call when URL redirections change (optional) |
AGILITY_API_MANAGEMENT_KEY, HOOTSUITE_ACCESS_TOKEN, HOOTSUITE_PROFILE_IDS | The demo's social posting when a blog post is published (optional) |
src/lib/types/env.d.ts declares the main variables on process.env, so they're typed everywhere in the code.
The repo has an AGENTS.md file that describes the architecture and conventions for AI coding assistants. The Agility CMS MCP server lets an assistant read and change your instance's models and content. The models and components in the demo's instance carry "use when / avoid when" guidance that agents read.