@tanstack/react-router 1.81.14 → 1.82.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.81.14",
3
+ "version": "1.82.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
package/src/route.ts CHANGED
@@ -434,7 +434,10 @@ export interface UpdatableRouteOptions<
434
434
  TLoaderDeps
435
435
  >,
436
436
  ) => void
437
- meta?: (ctx: {
437
+ headers?: (ctx: {
438
+ loaderData: ResolveLoaderData<TLoaderFn>
439
+ }) => Record<string, string>
440
+ head?: (ctx: {
438
441
  matches: Array<
439
442
  RouteMatch<
440
443
  TRouteId,
@@ -466,13 +469,12 @@ export interface UpdatableRouteOptions<
466
469
  TLoaderDeps
467
470
  >
468
471
  params: ResolveAllParamsFromParent<TParentRoute, TParams>
469
- loaderData: ResolveLoaderData<TLoaderFn>
470
- }) => Array<React.JSX.IntrinsicElements['meta']>
471
- links?: () => Array<React.JSX.IntrinsicElements['link']>
472
- scripts?: () => Array<React.JSX.IntrinsicElements['script']>
473
- headers?: (ctx: {
474
- loaderData: ResolveLoaderData<TLoaderFn>
475
- }) => Record<string, string>
472
+ loaderData: ResolveLoaderData<TLoaderFn> | undefined
473
+ }) => {
474
+ links?: Array<React.JSX.IntrinsicElements['link']> | undefined
475
+ scripts?: Array<React.JSX.IntrinsicElements['script']> | undefined
476
+ meta?: Array<React.JSX.IntrinsicElements['meta']> | undefined
477
+ }
476
478
  ssr?: boolean
477
479
  }
478
480
 
package/src/router.ts CHANGED
@@ -1298,25 +1298,30 @@ export class Router<
1298
1298
  : loaderDeps,
1299
1299
  invalid: false,
1300
1300
  preload: false,
1301
- links: route.options.links?.(),
1302
- scripts: route.options.scripts?.(),
1301
+ links: undefined,
1302
+ scripts: undefined,
1303
+ meta: undefined,
1303
1304
  staticData: route.options.staticData || {},
1304
1305
  loadPromise: createControlledPromise(),
1305
1306
  fullPath: route.fullPath,
1306
1307
  }
1307
1308
  }
1308
1309
 
1309
- // If it's already a success, update the meta and headers
1310
+ const headFnContent = route.options.head?.({
1311
+ matches,
1312
+ match,
1313
+ params: match.params,
1314
+ loaderData: match.loaderData ?? undefined,
1315
+ })
1316
+
1317
+ match.links = headFnContent?.links
1318
+ match.scripts = headFnContent?.scripts
1319
+ match.meta = headFnContent?.meta
1320
+
1321
+ // If it's already a success, update the headers
1310
1322
  // These may get updated again if the match is refreshed
1311
1323
  // due to being stale
1312
1324
  if (match.status === 'success') {
1313
- match.meta = route.options.meta?.({
1314
- matches,
1315
- match,
1316
- params: match.params,
1317
- loaderData: match.loaderData,
1318
- })
1319
-
1320
1325
  match.headers = route.options.headers?.({
1321
1326
  loaderData: match.loaderData,
1322
1327
  })
@@ -2516,12 +2521,13 @@ export class Router<
2516
2521
 
2517
2522
  await potentialPendingMinPromise()
2518
2523
 
2519
- const meta = route.options.meta?.({
2524
+ const headFnContent = route.options.head?.({
2520
2525
  matches,
2521
2526
  match: this.getMatch(matchId)!,
2522
2527
  params: this.getMatch(matchId)!.params,
2523
2528
  loaderData,
2524
2529
  })
2530
+ const meta = headFnContent?.meta
2525
2531
 
2526
2532
  const headers = route.options.headers?.({
2527
2533
  loaderData,