Functions
Complete reference for all generate-metadata functions in TanStack Start
A simple guide to using generate-metadata functions in your TanStack Start application.
Quick Start
First, create a metadata client:
getHead()
Generate AI-powered metadata for individual routes.
Basic Usage
Dynamic Routes
For routes with dynamic parameters, include them in the path:
With Search Parameters
Include search parameters in the path for better caching:
getRootHead()
Generate metadata for layout components.
Simple Layout
Layout with Fallback
If you want default metadata when the API is unavailable:
Fallback Metadata
Use fallback metadata when the API is unavailable. It's optional but recommended:
Override Metadata
Use override
to force certain metadata values, regardless of what the API returns:
Complete Example
Here's a complete example showing all features:
Common Patterns
E-commerce Product Pages
Blog Posts
Category Pages
revalidateHandler()
Creates a Hono app instance for handling cache revalidation requests. This method allows you to programmatically clear cached metadata when your content changes.
Note: Unlike the Next.js adapter which returns Next.js-compatible route handlers, this method returns a Hono app instance that you can integrate with your TanStack Start application.
Basic Usage
Custom Revalidation Logic
You can provide a custom revalidatePath
function to handle revalidation according to your needs:
API Endpoint
The handler creates a POST /revalidate
endpoint that accepts:
Authentication
The endpoint supports two authentication methods:
- Bearer Token: Include
Authorization: Bearer <secret>
header - HMAC Signature: For webhook integrations (see webhook verification docs)
Response
On success:
That's it! Your TanStack Start app now has AI-powered metadata generation.