app-router-setup

A project guide for a Next.js application that uses the App Router, Sitecore Content SDK, TypeScript, and next-intl for multiple languages. The App Router organizes pages and layouts through files and uses server components by default.

In plain words
What is it for?
Use it when setting up the project, configuring environment variables, creating routes and layouts, deciding between server and client components, or building Sitecore-backed UI.
Why use it?
It gives developers the conventions needed to start, build, and extend this specific kind of Sitecore website. This avoids confusion about where pages, components, configuration, and language support belong.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/sitecore/xmcloud-starter-js/app-router-setup
Clone the repo
git clone --depth 1 https://github.com/Sitecore/xmcloud-starter-js

Made for: Cursor.

Per session 624 This file is loaded in full into every session.
When invoked 624 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00624 $0.00624
Opus 5 $0.00312 $0.00312
Sonnet 5 $0.00125 $0.00125
Haiku 4.5 $0.00062 $0.00062

Measured 2d ago against content hash e58bd49ecaf4, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

app-router-setup scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

examples/basic-nextjs/.cursor/rules/app-router-setup.mdc · 117 lines

How it starts

The opening of the file, as written. The whole thing — 117 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Sitecore Content SDK Next.js App Router Project

Project Overview

This is a Sitecore Content SDK application built with Next.js App Router. This project uses the latest Next.js features for improved performance and developer experience.

Key Technologies:

  • Next.js App Router (React Server Components)
  • Sitecore Content SDK
  • TypeScript
  • Sitecore XM Cloud
  • next-intl for internationalization

Getting Started

Development Workflow:

  1. Install dependencies: npm install
  2. Configure environment variables (copy .env.example to .env.local)
  3. Start development server: npm run dev
  4. Build for production: npm run build

App Router Specifics:

  • Server Components by default
  • Client Components when interactivity needed
  • File-based routing in src/app/ directory
  • Layout files for shared UI elements

Project Structure

src/
  app/                 # App Router pages and layouts
  components/          # React-specific SDK
  lib/                 # Configuration and utilities
  i18n/                # Internationalization setup

Component Development:

  • Server Components for data fetching and static content
  • Client Components for interactivity (use 'use client')
  • Shared components in src/components/
  • Follow Sitecore field handling patterns

App Router Best Practices

Server vs Client Components:

  • Use Server Components for Sitecore content rendering
  • Use Client Components for user interactions
  • Minimize client-side JavaScript
  • Leverage server-side data fetching

Routing and Layouts:

  • Use layout.tsx for shared page structure
  • Implement loading.tsx for loading states
  • Create error.tsx for error boundaries
  • Use page.tsx for route content

Sitecore Integration

Content Rendering:

  • Fetch Sitecore data in Server Components
  • Use layout service for page structure
  • Handle content preview scenarios
  • Implement proper error handling

Performance:

  • Leverage Server Components for better performance
  • Use streaming for improved loading experience
  • Implement proper caching strategies
  • Optimize images with Next.js Image component

Read the full file on GitHub · 117 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 117 lines · 624 tokens per session scan A e58bd49ecaf4

Subscribe to this mod's changes

app-router-setup is a cursor rule published in the GitHub repository Sitecore/xmcloud-starter-js (29 stars, last pushed 8d ago), licensed Apache-2.0. It adds 624 tokens to every session, about $0.0031 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.