Libraries · Reference
SEO Metadata
A framework-neutral SEO helper for TanStack Start head metadata, localized canonical links, Open Graph and Twitter tags, and derived JSON-LD.
Last updated August 17, 2026
Overview
createSeo creates a configured SEO helper for public pages. Put site-wide values such as the origin, supported locales, site name, and organization profiles in the factory, then pass only page-specific metadata to each page. The lower-level seo function remains available for one-off configurations.
Install
bunx shadcn@latest add @krak-stack/seoThe item installs src/lib/seo.ts. The same helper is available from the package export @krak-stack/registry/seo.
Configure Site Defaults
import { createSeo } from "@/lib/seo";
const siteSeo = createSeo({
origin: "https://example.com",
locales: ["en", "fr"],
siteName: "Example",
sameAs: ["https://github.com/example/project"],
});Page Metadata
Use the configured helper in a TanStack Start route. path defaults to /, and defaultLocale falls back to the first configured locale.
export const Route = createFileRoute("/")({
head: () =>
siteSeo({
title: "Example",
description: "Production-ready building blocks for TanStack apps.",
locale: "en",
image: "https://example.com/og.png",
}),
});The returned meta, links, and scripts can be spread into a route head configuration. Optional values are omitted instead of producing empty tags.
Documentation Pages
Pass type: "article" and a page path for documentation or other editorial pages. This changes the JSON-LD payload from WebSite to Article.
siteSeo({
title: "Introduction",
description: "Learn the core concepts.",
path: "/docs/introduction",
locale: "en",
type: "article",
});Factory Options
origin- site origin used to derive canonical and localized URLslocales- supported locales used for alternate linksdefaultLocale- locale used for thex-defaultlinksiteName- site and publisher nametwitterCreatorandtwitterSite- Twitter profile handlessameAs- organization profile URLs included in JSON-LD
Page Options
title- required page titledescription- description used by search and social metadatapath- page path, defaulting to/locale- current page localeurl- explicit canonical URL when it cannot be derivedimage- social preview image URLrobots- custom robots directive, defaulting toindex, followtype-websiteorarticle, defaulting towebsite