/sitecore-content-sdk-angular:content-sdk-angular-loader-authoringfrom Sitecore Content SDK - Angular
Writes Content SDK loaders for Angular in src/content-sdk/loaders/ without Angular DI: LoaderContext helpers, LOADERS registry, /_data. Use when adding or debugging a loader.
Ships in Sitecore Content SDK - Angular. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A loader is a plain function that fetches Sitecore data for a route. Read this skill before editing anything under src/content-sdk/. Paths are relative to the head app.
src/content-sdk/.Read first: src/content-sdk/loaders/page.loader.ts, src/content-sdk/loaders/index.ts.
Why loaders live under src/content-sdk/, not src/app/. A loader runs from two places:
loaderResolver(id) in src/app/app.routes.ts runs inside the Angular injector and delegates to the server loader runner provided by provideServerLoaderRunner() (src/app/app.config.server.ts).createLoaderDataServiceMiddleware(config, { loaders: LOADERS, cache }) in src/server.ts serves POST /_data for client-side navigation. There is no Angular injector in this path.The folder name encodes the contract: src/content-sdk/ is framework-agnostic Sitecore integration, src/app/ is the Angular DI world. A loader moved into src/app/ with an injected service appears to work under SSR and then fails at runtime the first time a client-side navigation hits /_data. loaderResolver() and the providers in app.config.ts / app.config.server.ts may use DI; that is SDK infrastructure, not loader code.
The LoaderFn contract:
type LoaderFn<T = unknown> = (ctx: LoaderContext) => Promise<T> | T | LoaderRedirectResult;
LoaderContext carries url, routeParams (with locale defaulted to scConfig.defaultLanguage), query, scParams (site and personalization variants written by the Express middleware) and, server-side, req and csdkRequestData.
Helpers from @sitecore-content-sdk/angular:
| Helper | Returns |
|---|---|
getLanguage(context) | Locale from the route params |
getSiteName(context) | Site resolved by createMultisiteMiddleware |
getVariantId(context) | Page variant from createPersonalizeMiddleware |
getComponentVariantIds(context) | Component variants from personalization |
getEditingPreviewData(context.csdkRequestData) | Editing/preview payload stashed by the editing render middleware |
splitLocaleFromPath(url, scConfig.angular.locales) | { locale, nonLocalePath } |
Reference shape (page.loader.ts: static imports, no inject()):
import type { LoaderFn, Page } from '@sitecore-content-sdk/angular';
import { NotFoundNavigationError, getEditingPreviewData, /* … */ } from '@sitecore-content-sdk/angular';
import scConfig from '../../../sitecore.config';
import { getClient } from '../client/sitecore-client';
export const pageLoader: LoaderFn<Page> = async (context) => {
const previewData = getEditingPreviewData(context.csdkRequestData);
const locale = getLanguage(context) || scConfig.defaultLanguage;
const { nonLocalePath } = splitLocaleFromPath(context.url, scConfig.angular.locales);
// getPreview / getPage
if (!page) throw new NotFoundNavigationError();
return page;
};
Error signalling:
throw new NotFoundNavigationError(). The router navigates to notFoundRoute (/404) and app.routes.server.ts maps it to HTTP 404.LoaderRedirectResult. Redirects are never written to the cache.LoaderHttpError and routes to errorRoute (/500).The single registry. src/content-sdk/loaders/index.ts exports one LOADERS object (page, dictionary, '404', '500'). The same object goes to provideLoaderRegistry(LOADERS) in app.config.ts and to createLoaderDataServiceMiddleware(config, { loaders: LOADERS, cache: loaderCache }) in server.ts. There is no separate server loader set.
Add a loader: create src/content-sdk/loaders/<name>.loader.ts as a plain LoaderFn with static imports only; export it from index.ts; add it to LOADERS; attach loaderResolver('<key>') to the route in src/app/app.routes.ts. The registry key and the resolver argument must match. Verify the result is JSON-serializable.
src/content-sdk/loaders/, never in src/app/.inject(), no constructor DI, no Angular services in a loader body or anywhere under src/content-sdk/.scConfig from sitecore.config.ts, getClient() from ../client/sitecore-client.LoaderContext argument with the helpers above.LOADERS object; the key must match the loaderResolver('<key>') argument in app.routes.ts.TransferState.throw new NotFoundNavigationError().src/app/ or to maintain a second server-side loader set.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub chris1415/sitecore-skills-pocs --plugin sitecore-content-sdk-angular18 skills in this plugin
/content-sdk-angular-component-data-strategyHow a component gets Sitecore data in an Angular Content SDK app: placeholder inputs, route resolve data, SitecoreContextService, no component-level fetch. Use when wiring data or it is missing after navigation. Not Next.js./content-sdk-angular-component-registrationRegisters components in .sitecore/component-map.ts and the SITECORE_COMPONENT_MAP token in an Angular Content SDK app. Use when a component shows as missing or the map changes. Not Next.js./content-sdk-angular-Other plugins' skills for the same job