Skip to content

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

shell
bunx shadcn@latest add @krak-stack/seo

The item installs src/lib/seo.ts. The same helper is available from the package export @krak-stack/registry/seo.

Configure Site Defaults

tsx
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.

tsx
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.

tsx
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 URLs
  • locales - supported locales used for alternate links
  • defaultLocale - locale used for the x-default link
  • siteName - site and publisher name
  • twitterCreator and twitterSite - Twitter profile handles
  • sameAs - organization profile URLs included in JSON-LD

Page Options

  • title - required page title
  • description - description used by search and social metadata
  • path - page path, defaulting to /
  • locale - current page locale
  • url - explicit canonical URL when it cannot be derived
  • image - social preview image URL
  • robots - custom robots directive, defaulting to index, follow
  • type - website or article, defaulting to website