seo
Give every page a title, a share preview and a sitemap entry so search engines and chat apps show it well.
Pages & routingClient Server
Every export of kitr/seo, read from the published type definitions. The guide shows them in use.
kitr/seo
cacheHeaders
function cacheHeaders(options?: {
maxAge?: number;
sMaxAge?: number;
staleWhileRevalidate?: number;
private?: boolean;
}): {
'cache-control': string;
};
Cache-Control helper for Start's headers route option.
jsonLd
function jsonLd(data: Record<string, unknown> & {
'@type': string;
}): {
type: string;
children: string;
};
A JSON-LD script for head().scripts: scripts: [jsonLd({ '@type': 'Article', headline })].
robotsTxt
function robotsTxt(config: SeoConfig): string | null;
robots.txt text from the config; the web platform writes it on build.
seo
function seo(input: SeoInput): {
meta: Record<string, string>[];
links: Record<string, string>[];
};
Meta tags for a route's head(): head: () => seo({ title, description }).
Covers title, description, Open Graph, Twitter cards, canonical and robots.
ssrRoute
function ssrRoute(mode: boolean | 'data-only'): {
readonly ssr: boolean | "data-only";
};
Route option presets. Spread into createFileRoute(...)({ ...ssrRoute('data-only'), ... }).
defineConfig
const defineConfig: <const C extends SeoConfig>(config: C) => C;
SeoConfig
interface SeoConfig {
/** Site-wide defaults for `seo()`. */
site?: SeoSite;
/** Default per-route rendering for a web platform in `ssr` mode: true (full SSR), 'data-only' or false. */
ssr?: boolean | 'data-only';
/** Routes to prerender at build time; `crawlLinks` follows links from them. A `static` web platform prerenders everything. */
prerender?: string[] | {
routes: string[];
crawlLinks?: boolean;
};
/** `robots.txt` rules written on build. `false` disables. */
robots?: false | {
allow?: string[];
disallow?: string[];
sitemap?: boolean;
};
}
SeoInput
interface SeoInput {
title?: string;
description?: string;
image?: string;
url?: string;
type?: 'website' | 'article' | 'product';
noIndex?: boolean;
keywords?: string[];
site?: SeoSite;
}
SeoSite
interface SeoSite {
name?: string;
/** Canonical origin (`https://example.com`). Turns on the sitemap for prerendered routes. */
url?: string;
image?: string;
twitter?: string;
locale?: string;
}