Skip to content
Source
Sign inSign up
TanStack/router
Open History to see the last commit

HeadContent.tsx

29 lines872 Bytes

1'use client'
2​
3import * as React from 'react'
4import { Asset } from './Asset'
5import { useRouter } from './useRouter'
6import { useTags } from './headContentUtils'
7import type { AssetCrossOriginConfig } from '@tanstack/router-core'
8​
9export interface HeadContentProps {
10 assetCrossOrigin?: AssetCrossOriginConfig
12​
13/**
14 * Render route-managed head tags (title, meta, links, styles, head scripts).
15 * Place inside the document head of your app shell.
16 * @link https://tanstack.com/router/latest/docs/framework/react/guide/document-head-management
17 */
18export function HeadContent(props: HeadContentProps) {
19 const tags = useTags(props.assetCrossOrigin)
20 const router = useRouter()
21 const nonce = router.options.ssr?.nonce
22 return (
23 <>
24 {tags.map((tag) => (
25 <Asset {...tag} key={`tsr-meta-${JSON.stringify(tag)}`} nonce={nonce} />
26 ))}
27 </>
28 )