@tanstack/react-router 1.168.13 → 1.168.14

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.
Files changed (144) hide show
  1. package/dist/cjs/Asset.cjs +1 -0
  2. package/dist/cjs/Asset.cjs.map +1 -1
  3. package/dist/cjs/CatchBoundary.cjs +1 -0
  4. package/dist/cjs/CatchBoundary.cjs.map +1 -1
  5. package/dist/cjs/ClientOnly.cjs +1 -0
  6. package/dist/cjs/ClientOnly.cjs.map +1 -1
  7. package/dist/cjs/HeadContent.cjs +1 -0
  8. package/dist/cjs/HeadContent.cjs.map +1 -1
  9. package/dist/cjs/HeadContent.dev.cjs +1 -0
  10. package/dist/cjs/HeadContent.dev.cjs.map +1 -1
  11. package/dist/cjs/Match.cjs +6 -5
  12. package/dist/cjs/Match.cjs.map +1 -1
  13. package/dist/cjs/Matches.cjs +4 -3
  14. package/dist/cjs/Matches.cjs.map +1 -1
  15. package/dist/cjs/RouterProvider.cjs +1 -0
  16. package/dist/cjs/RouterProvider.cjs.map +1 -1
  17. package/dist/cjs/Scripts.cjs +3 -2
  18. package/dist/cjs/Scripts.cjs.map +1 -1
  19. package/dist/cjs/Transitioner.cjs +6 -5
  20. package/dist/cjs/Transitioner.cjs.map +1 -1
  21. package/dist/cjs/headContentUtils.cjs +1 -1
  22. package/dist/cjs/headContentUtils.cjs.map +1 -1
  23. package/dist/cjs/index.cjs +1 -0
  24. package/dist/cjs/index.d.cts +1 -1
  25. package/dist/cjs/index.dev.cjs +1 -0
  26. package/dist/cjs/link.cjs +2 -1
  27. package/dist/cjs/link.cjs.map +1 -1
  28. package/dist/cjs/matchContext.cjs +1 -0
  29. package/dist/cjs/matchContext.cjs.map +1 -1
  30. package/dist/cjs/not-found.cjs +1 -1
  31. package/dist/cjs/not-found.cjs.map +1 -1
  32. package/dist/cjs/routerContext.cjs +1 -0
  33. package/dist/cjs/routerContext.cjs.map +1 -1
  34. package/dist/cjs/routerStores.cjs +2 -2
  35. package/dist/cjs/routerStores.cjs.map +1 -1
  36. package/dist/cjs/ssr/RouterClient.cjs +1 -1
  37. package/dist/cjs/ssr/RouterClient.cjs.map +1 -1
  38. package/dist/cjs/ssr/renderRouterToStream.cjs +2 -2
  39. package/dist/cjs/ssr/renderRouterToStream.cjs.map +1 -1
  40. package/dist/cjs/ssr/renderRouterToString.cjs +1 -1
  41. package/dist/cjs/ssr/renderRouterToString.cjs.map +1 -1
  42. package/dist/cjs/useBlocker.cjs +1 -0
  43. package/dist/cjs/useBlocker.cjs.map +1 -1
  44. package/dist/cjs/useCanGoBack.cjs +1 -1
  45. package/dist/cjs/useCanGoBack.cjs.map +1 -1
  46. package/dist/cjs/useLocation.cjs +1 -1
  47. package/dist/cjs/useLocation.cjs.map +1 -1
  48. package/dist/cjs/useMatch.cjs +3 -3
  49. package/dist/cjs/useMatch.cjs.map +1 -1
  50. package/dist/cjs/useNavigate.cjs +1 -0
  51. package/dist/cjs/useNavigate.cjs.map +1 -1
  52. package/dist/cjs/useRouter.cjs +1 -0
  53. package/dist/cjs/useRouter.cjs.map +1 -1
  54. package/dist/cjs/useRouterState.cjs +2 -1
  55. package/dist/cjs/useRouterState.cjs.map +1 -1
  56. package/dist/cjs/utils.cjs +1 -0
  57. package/dist/cjs/utils.cjs.map +1 -1
  58. package/dist/esm/Asset.js +1 -0
  59. package/dist/esm/Asset.js.map +1 -1
  60. package/dist/esm/CatchBoundary.js +1 -0
  61. package/dist/esm/CatchBoundary.js.map +1 -1
  62. package/dist/esm/ClientOnly.js +1 -0
  63. package/dist/esm/ClientOnly.js.map +1 -1
  64. package/dist/esm/HeadContent.dev.js +1 -0
  65. package/dist/esm/HeadContent.dev.js.map +1 -1
  66. package/dist/esm/HeadContent.js +1 -0
  67. package/dist/esm/HeadContent.js.map +1 -1
  68. package/dist/esm/Match.js +6 -5
  69. package/dist/esm/Match.js.map +1 -1
  70. package/dist/esm/Matches.js +4 -3
  71. package/dist/esm/Matches.js.map +1 -1
  72. package/dist/esm/RouterProvider.js +1 -0
  73. package/dist/esm/RouterProvider.js.map +1 -1
  74. package/dist/esm/Scripts.js +3 -2
  75. package/dist/esm/Scripts.js.map +1 -1
  76. package/dist/esm/Transitioner.js +6 -5
  77. package/dist/esm/Transitioner.js.map +1 -1
  78. package/dist/esm/headContentUtils.js +1 -1
  79. package/dist/esm/headContentUtils.js.map +1 -1
  80. package/dist/esm/index.d.ts +1 -1
  81. package/dist/esm/index.dev.js +1 -0
  82. package/dist/esm/index.js +1 -0
  83. package/dist/esm/link.js +2 -1
  84. package/dist/esm/link.js.map +1 -1
  85. package/dist/esm/matchContext.js +1 -0
  86. package/dist/esm/matchContext.js.map +1 -1
  87. package/dist/esm/not-found.js +1 -1
  88. package/dist/esm/not-found.js.map +1 -1
  89. package/dist/esm/routerContext.js +1 -0
  90. package/dist/esm/routerContext.js.map +1 -1
  91. package/dist/esm/routerStores.js +3 -3
  92. package/dist/esm/routerStores.js.map +1 -1
  93. package/dist/esm/ssr/RouterClient.js +1 -1
  94. package/dist/esm/ssr/RouterClient.js.map +1 -1
  95. package/dist/esm/ssr/renderRouterToStream.js +2 -2
  96. package/dist/esm/ssr/renderRouterToStream.js.map +1 -1
  97. package/dist/esm/ssr/renderRouterToString.js +1 -1
  98. package/dist/esm/ssr/renderRouterToString.js.map +1 -1
  99. package/dist/esm/useBlocker.js +1 -0
  100. package/dist/esm/useBlocker.js.map +1 -1
  101. package/dist/esm/useCanGoBack.js +1 -1
  102. package/dist/esm/useCanGoBack.js.map +1 -1
  103. package/dist/esm/useLocation.js +1 -1
  104. package/dist/esm/useLocation.js.map +1 -1
  105. package/dist/esm/useMatch.js +3 -3
  106. package/dist/esm/useMatch.js.map +1 -1
  107. package/dist/esm/useNavigate.js +1 -0
  108. package/dist/esm/useNavigate.js.map +1 -1
  109. package/dist/esm/useRouter.js +1 -0
  110. package/dist/esm/useRouter.js.map +1 -1
  111. package/dist/esm/useRouterState.js +2 -1
  112. package/dist/esm/useRouterState.js.map +1 -1
  113. package/dist/esm/utils.js +1 -0
  114. package/dist/esm/utils.js.map +1 -1
  115. package/package.json +2 -2
  116. package/src/Asset.tsx +2 -0
  117. package/src/CatchBoundary.tsx +2 -0
  118. package/src/ClientOnly.tsx +2 -0
  119. package/src/HeadContent.dev.tsx +2 -0
  120. package/src/HeadContent.tsx +2 -0
  121. package/src/Match.tsx +8 -6
  122. package/src/Matches.tsx +5 -3
  123. package/src/RouterProvider.tsx +2 -0
  124. package/src/Scripts.tsx +3 -4
  125. package/src/Transitioner.tsx +10 -10
  126. package/src/headContentUtils.tsx +1 -1
  127. package/src/index.dev.tsx +2 -0
  128. package/src/index.tsx +5 -0
  129. package/src/link.tsx +3 -1
  130. package/src/matchContext.tsx +2 -0
  131. package/src/not-found.tsx +2 -2
  132. package/src/routerContext.tsx +2 -0
  133. package/src/routerStores.ts +3 -3
  134. package/src/ssr/RouterClient.tsx +1 -1
  135. package/src/ssr/renderRouterToStream.tsx +2 -2
  136. package/src/ssr/renderRouterToString.tsx +1 -1
  137. package/src/useBlocker.tsx +2 -0
  138. package/src/useCanGoBack.ts +1 -1
  139. package/src/useLocation.tsx +1 -1
  140. package/src/useMatch.tsx +4 -3
  141. package/src/useNavigate.tsx +2 -0
  142. package/src/useRouter.tsx +2 -0
  143. package/src/useRouterState.tsx +3 -1
  144. package/src/utils.ts +1 -0
@@ -194,7 +194,7 @@ export const useTags = (assetCrossOrigin?: AssetCrossOriginConfig) => {
194
194
  return buildTagsFromMatches(
195
195
  router,
196
196
  nonce,
197
- router.stores.activeMatchesSnapshot.state,
197
+ router.stores.activeMatchesSnapshot.get(),
198
198
  assetCrossOrigin,
199
199
  )
200
200
  }
package/src/index.dev.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  // Development entry point - re-exports everything from index.tsx
2
4
  // but overrides HeadContent with the dev version that handles
3
5
  // dev styles cleanup after hydration
package/src/index.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  export {
2
4
  defer,
3
5
  isMatch,
@@ -326,6 +328,9 @@ export type {
326
328
  InferSelected,
327
329
  ValidateUseSearchResult,
328
330
  ValidateUseParamsResult,
331
+ SerializerExtensions,
332
+ RegisteredSerializableInput,
333
+ Serializable,
329
334
  } from '@tanstack/router-core'
330
335
 
331
336
  export { ScriptOnce } from './ScriptOnce'
package/src/link.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import { useStore } from '@tanstack/react-store'
3
5
  import { flushSync } from 'react-dom'
@@ -205,7 +207,7 @@ export function useLinkProps<
205
207
  const isActive = (() => {
206
208
  if (externalLink) return false
207
209
 
208
- const currentLocation = router.stores.location.state
210
+ const currentLocation = router.stores.location.get()
209
211
 
210
212
  const exact = activeOptions?.exact ?? false
211
213
 
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
 
3
5
  export const matchContext = React.createContext<string | undefined>(undefined)
package/src/not-found.tsx CHANGED
@@ -15,8 +15,8 @@ export function CatchNotFound(props: {
15
15
  const router = useRouter()
16
16
 
17
17
  if (isServer ?? router.isServer) {
18
- const pathname = router.stores.location.state.pathname
19
- const status = router.stores.status.state
18
+ const pathname = router.stores.location.get().pathname
19
+ const status = router.stores.status.get()
20
20
  const resetKey = `not-found-${pathname}-${status}`
21
21
 
22
22
  return (
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import type { AnyRouter } from '@tanstack/router-core'
3
5
 
@@ -1,4 +1,4 @@
1
- import { batch, createStore } from '@tanstack/react-store'
1
+ import { batch, createAtom } from '@tanstack/react-store'
2
2
  import {
3
3
  createNonReactiveMutableStore,
4
4
  createNonReactiveReadonlyStore,
@@ -19,8 +19,8 @@ export const getStoreFactory: GetStoreConfig = (opts) => {
19
19
  }
20
20
  }
21
21
  return {
22
- createMutableStore: createStore,
23
- createReadonlyStore: createStore,
22
+ createMutableStore: createAtom,
23
+ createReadonlyStore: createAtom,
24
24
  batch: batch,
25
25
  }
26
26
  }
@@ -7,7 +7,7 @@ let hydrationPromise: Promise<void | Array<Array<void>>> | undefined
7
7
 
8
8
  export function RouterClient(props: { router: AnyRouter }) {
9
9
  if (!hydrationPromise) {
10
- if (!props.router.stores.matchesId.state.length) {
10
+ if (!props.router.stores.matchesId.get().length) {
11
11
  hydrationPromise = hydrate(props.router)
12
12
  } else {
13
13
  hydrationPromise = Promise.resolve()
@@ -36,7 +36,7 @@ export const renderRouterToStream = async ({
36
36
  stream as unknown as ReadableStream,
37
37
  )
38
38
  return new Response(responseStream as any, {
39
- status: router.stores.statusCode.state,
39
+ status: router.stores.statusCode.get(),
40
40
  headers: responseHeaders,
41
41
  })
42
42
  }
@@ -79,7 +79,7 @@ export const renderRouterToStream = async ({
79
79
  reactAppPassthrough,
80
80
  )
81
81
  return new Response(responseStream as any, {
82
- status: router.stores.statusCode.state,
82
+ status: router.stores.statusCode.get(),
83
83
  headers: responseHeaders,
84
84
  })
85
85
  }
@@ -21,7 +21,7 @@ export const renderRouterToString = async ({
21
21
  }
22
22
 
23
23
  return new Response(`<!DOCTYPE html>${html}`, {
24
- status: router.stores.statusCode.state,
24
+ status: router.stores.statusCode.get(),
25
25
  headers: responseHeaders,
26
26
  })
27
27
  } catch (error) {
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import { useRouter } from './useRouter'
3
5
  import type {
@@ -6,7 +6,7 @@ export function useCanGoBack() {
6
6
  const router = useRouter()
7
7
 
8
8
  if (isServer ?? router.isServer) {
9
- return router.stores.location.state.state.__TSR_index !== 0
9
+ return router.stores.location.get().state.__TSR_index !== 0
10
10
  }
11
11
 
12
12
  // eslint-disable-next-line react-hooks/rules-of-hooks -- condition is static
@@ -52,7 +52,7 @@ export function useLocation<
52
52
  const router = useRouter<TRouter>()
53
53
 
54
54
  if (isServer ?? router.isServer) {
55
- const location = router.stores.location.state
55
+ const location = router.stores.location.get()
56
56
  return (
57
57
  opts?.select ? opts.select(location as any) : location
58
58
  ) as UseLocationResult<TRouter, TSelected>
package/src/useMatch.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import { useStore } from '@tanstack/react-store'
3
5
  import { invariant, replaceEqualDeep } from '@tanstack/router-core'
@@ -19,9 +21,8 @@ import type {
19
21
  } from '@tanstack/router-core'
20
22
 
21
23
  const dummyStore = {
22
- state: undefined,
23
24
  get: () => undefined,
24
- subscribe: () => () => {},
25
+ subscribe: () => ({ unsubscribe: () => {} }),
25
26
  } as any
26
27
 
27
28
  export interface UseMatchBaseOptions<
@@ -117,7 +118,7 @@ export function useMatch<
117
118
  : undefined
118
119
 
119
120
  if (isServer ?? router.isServer) {
120
- const match = matchStore?.state
121
+ const match = matchStore?.get()
121
122
  if ((opts.shouldThrow ?? true) && !match) {
122
123
  if (process.env.NODE_ENV !== 'production') {
123
124
  throw new Error(
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import { useLayoutEffect } from './utils'
3
5
  import { useRouter } from './useRouter'
package/src/useRouter.tsx CHANGED
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import * as React from 'react'
2
4
  import { routerContext } from './routerContext'
3
5
  import type { AnyRouter, RegisteredRouter } from '@tanstack/router-core'
@@ -1,3 +1,5 @@
1
+ 'use client'
2
+
1
3
  import { useStore } from '@tanstack/react-store'
2
4
  import { useRef } from 'react'
3
5
  import { replaceEqualDeep } from '@tanstack/router-core'
@@ -57,7 +59,7 @@ export function useRouterState<
57
59
  // Avoid subscribing to the store (and any structural sharing work) on the server.
58
60
  const _isServer = isServer ?? router.isServer
59
61
  if (_isServer) {
60
- const state = router.stores.__store.state as RouterState<
62
+ const state = router.stores.__store.get() as RouterState<
61
63
  TRouter['routeTree']
62
64
  >
63
65
  return (opts?.select ? opts.select(state) : state) as UseRouterStateResult<
package/src/utils.ts CHANGED
@@ -1,3 +1,4 @@
1
+ 'use client'
1
2
  import * as React from 'react'
2
3
 
3
4
  // Safe version of React.use() that will not cause compilation errors against