Skip to content

Commit 4ae6ca9

Browse files
authored
feat(start): move scripts,links, and meta to the head (#2571)
This minor is non-breaking for Router users, since it's undocumented to the public API, but **is breaking** for Start alpha users. This changes the options signature for meta from this: ```tsx createRoute({ meta: () => [ ... ], links: () => [ ... ], }) ``` to this: ```tsx createRoute({ head: () => ({ meta: [ ... ], links: [ ... ], }) }) ```
1 parent acd33f7 commit 4ae6ca9

File tree

118 files changed

+1009
-916
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+1009
-916
lines changed

docs/framework/react/start/getting-started.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,20 @@ import { Meta, Scripts } from '@tanstack/start'
199199
import type { ReactNode } from 'react'
200200

201201
export const Route = createRootRoute({
202-
meta: () => [
203-
{
204-
charSet: 'utf-8',
205-
},
206-
{
207-
name: 'viewport',
208-
content: 'width=device-width, initial-scale=1',
209-
},
210-
{
211-
title: 'TanStack Start Starter',
212-
},
213-
],
202+
head: () => ({
203+
meta: [
204+
{
205+
charSet: 'utf-8',
206+
},
207+
{
208+
name: 'viewport',
209+
content: 'width=device-width, initial-scale=1',
210+
},
211+
{
212+
title: 'TanStack Start Starter',
213+
},
214+
],
215+
}),
214216
component: RootComponent,
215217
})
216218

e2e/react-router/basic-esbuild-file-based/src/routes/posts.$postId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ErrorComponentProps } from '@tanstack/react-router'
55

66
export const Route = createFileRoute('/posts/$postId')({
77
loader: async ({ params: { postId } }) => fetchPost(postId),
8-
errorComponent: PostErrorComponent as any,
8+
errorComponent: PostErrorComponent,
99
notFoundComponent: () => {
1010
return <p>Post not found</p>
1111
},

e2e/react-router/basic-file-based/src/routes/posts.$postId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { ErrorComponentProps } from '@tanstack/react-router'
55

66
export const Route = createFileRoute('/posts/$postId')({
77
loader: async ({ params: { postId } }) => fetchPost(postId),
8-
errorComponent: PostErrorComponent as any,
8+
errorComponent: PostErrorComponent,
99
notFoundComponent: () => {
1010
return <p>Post not found</p>
1111
},

e2e/react-router/basic-react-query-file-based/src/routes/posts.$postId.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const Route = createFileRoute('/posts/$postId')({
2020
component: PostComponent,
2121
})
2222

23-
export function PostErrorComponent({ error, reset }: ErrorComponentProps) {
23+
export function PostErrorComponent({ error }: ErrorComponentProps) {
2424
const router = useRouter()
2525
if (error instanceof PostNotFoundError) {
2626
return <div>{error.message}</div>

e2e/react-router/basic-react-query/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react'
22
import ReactDOM from 'react-dom/client'
33
import {
44
ErrorComponent,
5-
type ErrorComponentProps,
65
Link,
76
Outlet,
87
RouterProvider,
@@ -20,6 +19,7 @@ import {
2019
useSuspenseQuery,
2120
} from '@tanstack/react-query'
2221
import { NotFoundError, postQueryOptions, postsQueryOptions } from './posts'
22+
import type { ErrorComponentProps } from '@tanstack/react-router'
2323

2424
const rootRoute = createRootRouteWithContext<{
2525
queryClient: QueryClient

e2e/react-router/basic-scroll-restoration/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ const router = createRouter({ routeTree, defaultPreload: 'intent' })
214214

215215
declare global {
216216
interface Window {
217-
invokeOrders: string[]
217+
invokeOrders: Array<string>
218218
}
219219
}
220220
window.invokeOrders = []

e2e/react-router/basic-virtual-file-based/src/routes/file-based-subtree/hello/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Link, createFileRoute } from '@tanstack/react-router'
1+
import { createFileRoute } from '@tanstack/react-router'
22

33
export const Route = createFileRoute('/classic/hello/')({
44
component: () => <div>This is the index</div>,

e2e/react-router/basic/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import ReactDOM from 'react-dom/client'
22
import {
33
ErrorComponent,
4-
type ErrorComponentProps,
54
Link,
65
Outlet,
76
RouterProvider,
@@ -11,6 +10,7 @@ import {
1110
} from '@tanstack/react-router'
1211
import { TanStackRouterDevtools } from '@tanstack/router-devtools'
1312
import { NotFoundError, fetchPost, fetchPosts } from './posts'
13+
import type { ErrorComponentProps } from '@tanstack/react-router'
1414

1515
const rootRoute = createRootRoute({
1616
component: RootComponent,

e2e/start/basic-auth/app/client.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/// <reference types="vinxi/types/client" />
12
import { hydrateRoot } from 'react-dom/client'
23
import { StartClient } from '@tanstack/start'
34
import { createRouter } from './router'

e2e/start/basic-auth/app/components/DefaultCatchBoundary.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import {
22
ErrorComponent,
3-
ErrorComponentProps,
43
Link,
54
rootRouteId,
65
useMatch,
76
useRouter,
87
} from '@tanstack/react-router'
8+
import type { ErrorComponentProps } from '@tanstack/react-router'
99

1010
export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
1111
const router = useRouter()

0 commit comments

Comments
 (0)