Skip to content

Commit

Permalink
feat: replace <Meta /> by <HeadContent /> and add dedicated headScrip…
Browse files Browse the repository at this point in the history
…ts (#3439)
  • Loading branch information
schiller-manuel authored Feb 14, 2025
1 parent 7d76812 commit 4c7caeb
Show file tree
Hide file tree
Showing 44 changed files with 510 additions and 346 deletions.
2 changes: 1 addition & 1 deletion docs/router/eslint/create-route-property-order.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The correct property order is as follows
- `context`
- `beforeLoad`
- `loader`
- `onEnter`, `onStay`, `onLeave`, `meta`, `links`, `scripts`, `headers`, `remountDeps`
- `onEnter`, `onStay`, `onLeave`, `head`, `scripts`, `headers`, `remountDeps`

All other properties are insensitive to the order as they do not depend on type inference.

Expand Down
5 changes: 2 additions & 3 deletions docs/router/framework/react/guide/tanstack-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,8 @@ Finally, we need to create the root of our application. This is the entry point

```tsx
// app/routes/__root.tsx
import { createRootRoute } from '@tanstack/react-router'
import { createRootRoute, HeadContent, Scripts } from '@tanstack/react-router'
import { Outlet } from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'

export const Route = createRootRoute({
Expand Down Expand Up @@ -231,7 +230,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
{children}
Expand Down
10 changes: 7 additions & 3 deletions docs/start/framework/react/build-from-scratch.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,13 @@ Finally, we need to create the root of our application. This is the entry point

```tsx
// app/routes/__root.tsx
import { Outlet, createRootRoute } from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import type { ReactNode } from 'react'
import {
Outlet,
createRootRoute,
HeadContent,
Scripts,
} from '@tanstack/react-router'

export const Route = createRootRoute({
head: () => ({
Expand Down Expand Up @@ -238,7 +242,7 @@ function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
{children}
Expand Down
10 changes: 7 additions & 3 deletions docs/start/framework/react/learn-the-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ Because it is **always rendered**, it is the perfect place to construct your app

```tsx
// app/routes/__root.tsx
import { Outlet, createRootRoute } from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import {
Outlet,
createRootRoute,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import type { ReactNode } from 'react'

export const Route = createRootRoute({
Expand Down Expand Up @@ -134,7 +138,7 @@ function RootDocument({ children }: Readonly<{ children: ReactNode }>) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
{children}
Expand Down
12 changes: 9 additions & 3 deletions e2e/start/basic-auth/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts, createServerFn } from '@tanstack/start'
import { createServerFn } from '@tanstack/start'
import * as React from 'react'

import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary.js'
Expand Down Expand Up @@ -93,7 +99,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
5 changes: 3 additions & 2 deletions e2e/start/basic-react-query/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRouteWithContext,
} from '@tanstack/react-router'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import type { QueryClient } from '@tanstack/react-query'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
Expand Down Expand Up @@ -77,7 +78,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
11 changes: 8 additions & 3 deletions e2e/start/basic-rsc/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
Expand Down Expand Up @@ -69,7 +74,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
10 changes: 7 additions & 3 deletions e2e/start/basic-tsr-config/src/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import * as React from 'react'
import { Outlet, createRootRoute } from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import {
HeadContent,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'

export const Route = createRootRoute({
head: () => ({
Expand Down Expand Up @@ -32,7 +36,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
{children}
Expand Down
11 changes: 8 additions & 3 deletions e2e/start/basic/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import * as React from 'react'
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'

import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
Expand Down Expand Up @@ -79,7 +84,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
12 changes: 9 additions & 3 deletions e2e/start/clerk-basic/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/// <reference types="vite/client" />
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import {
ClerkProvider,
SignInButton,
Expand All @@ -8,7 +14,7 @@ import {
UserButton,
} from '@clerk/tanstack-start'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts, createServerFn } from '@tanstack/start'
import { createServerFn } from '@tanstack/start'
import * as React from 'react'
import { getAuth } from '@clerk/tanstack-start/server'
import { getWebRequest } from '@tanstack/start/server'
Expand Down Expand Up @@ -90,7 +96,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
5 changes: 3 additions & 2 deletions e2e/start/scroll-restoration/app/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
Outlet,
createRootRoute,
linkOptions,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
import appCss from '~/styles/app.css?url'
Expand Down Expand Up @@ -73,7 +74,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<Nav type="header" />
Expand Down
10 changes: 7 additions & 3 deletions e2e/start/website/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Outlet, createRootRoute } from '@tanstack/react-router'
import {
Outlet,
createRootRoute,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
Expand Down Expand Up @@ -68,7 +72,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
{children}
Expand Down
5 changes: 3 additions & 2 deletions examples/react/basic-ssr-file-based/src/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import {
Link,
Outlet,
createRootRouteWithContext,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import type { RouterContext } from '../routerContext'

export const Route = createRootRouteWithContext<RouterContext>()({
Expand Down Expand Up @@ -50,7 +51,7 @@ function RootComponent() {
return (
<html lang="en">
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import {
Link,
Outlet,
createRootRouteWithContext,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { Meta, Scripts } from '@tanstack/start'
import type { RouterContext } from '../routerContext'

export const Route = createRootRouteWithContext<RouterContext>()({
Expand Down Expand Up @@ -51,7 +52,7 @@ function RootComponent() {
return (
<html lang="en">
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
12 changes: 9 additions & 3 deletions examples/react/start-basic-auth/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts, createServerFn } from '@tanstack/start'
import { createServerFn } from '@tanstack/start'
import * as React from 'react'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary.js'
import { NotFound } from '~/components/NotFound.js'
Expand Down Expand Up @@ -92,7 +98,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
5 changes: 3 additions & 2 deletions examples/react/start-basic-react-query/app/routes/__root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import {
Link,
Outlet,
createRootRouteWithContext,
HeadContent,
Scripts,
} from '@tanstack/react-router'
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import type { QueryClient } from '@tanstack/react-query'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
Expand Down Expand Up @@ -77,7 +78,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
11 changes: 8 additions & 3 deletions examples/react/start-basic-rsc/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
Expand Down Expand Up @@ -69,7 +74,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
11 changes: 8 additions & 3 deletions examples/react/start-basic-static/app/routes/__root.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { Link, Outlet, createRootRoute } from '@tanstack/react-router'
import {
HeadContent,
Link,
Outlet,
Scripts,
createRootRoute,
} from '@tanstack/react-router'
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
import { Meta, Scripts } from '@tanstack/start'
import * as React from 'react'
import { DefaultCatchBoundary } from '~/components/DefaultCatchBoundary'
import { NotFound } from '~/components/NotFound'
Expand Down Expand Up @@ -69,7 +74,7 @@ function RootDocument({ children }: { children: React.ReactNode }) {
return (
<html>
<head>
<Meta />
<HeadContent />
</head>
<body>
<div className="p-2 flex gap-2 text-lg">
Expand Down
Loading

0 comments on commit 4c7caeb

Please sign in to comment.