@tanstack/react-router 1.134.18 → 1.135.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.
@@ -17,4 +17,5 @@ function subscribe() {
17
17
  };
18
18
  }
19
19
  exports.ClientOnly = ClientOnly;
20
+ exports.useHydrated = useHydrated;
20
21
  //# sourceMappingURL=ClientOnly.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientOnly.cjs","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\n/**\n * Render children only after client hydration; otherwise render `fallback`.\n * Useful for components that require browser-only APIs.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\n/**\n * Return a boolean indicating whether client hydration has occurred.\n */\nfunction useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"names":["jsx"],"mappings":";;;;AAmCO,SAAS,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,SAAO,YAAA,IACLA,2BAAAA,IAAC,MAAM,UAAN,EAAgB,SAAA,CAAS,IAE1BA,2BAAAA,IAAC,MAAM,UAAN,EAAgB,UAAA,SAAA,CAAS;AAE9B;AAwBA,SAAS,cAAuB;AAC9B,SAAO,MAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;;"}
1
+ {"version":3,"file":"ClientOnly.cjs","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\n/**\n * Render children only after client hydration; otherwise render `fallback`.\n * Useful for components that require browser-only APIs.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\n/**\n * Return a boolean indicating whether client hydration has occurred.\n */\nexport function useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"names":["jsx"],"mappings":";;;;AAmCO,SAAS,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,SAAO,YAAA,IACLA,2BAAAA,IAAC,MAAM,UAAN,EAAgB,SAAA,CAAS,IAE1BA,2BAAAA,IAAC,MAAM,UAAN,EAAgB,UAAA,SAAA,CAAS;AAE9B;AAwBO,SAAS,cAAuB;AACrC,SAAO,MAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;;;"}
@@ -32,3 +32,26 @@ export interface ClientOnlyProps {
32
32
  * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent
33
33
  */
34
34
  export declare function ClientOnly({ children, fallback }: ClientOnlyProps): import("react/jsx-runtime").JSX.Element;
35
+ /**
36
+ * Return a boolean indicating if the JS has been hydrated already.
37
+ * When doing Server-Side Rendering, the result will always be false.
38
+ * When doing Client-Side Rendering, the result will always be false on the
39
+ * first render and true from then on. Even if a new component renders it will
40
+ * always start with true.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * // Disable a button that needs JS to work.
45
+ * let hydrated = useHydrated()
46
+ * return (
47
+ * <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
48
+ * Click me
49
+ * </button>
50
+ * )
51
+ * ```
52
+ * @returns True if the JS has been hydrated already, false otherwise.
53
+ */
54
+ /**
55
+ * Return a boolean indicating whether client hydration has occurred.
56
+ */
57
+ export declare function useHydrated(): boolean;
@@ -211,6 +211,7 @@ exports.useAwaited = awaited.useAwaited;
211
211
  exports.CatchBoundary = CatchBoundary.CatchBoundary;
212
212
  exports.ErrorComponent = CatchBoundary.ErrorComponent;
213
213
  exports.ClientOnly = ClientOnly.ClientOnly;
214
+ exports.useHydrated = ClientOnly.useHydrated;
214
215
  exports.FileRoute = fileRoute.FileRoute;
215
216
  exports.FileRouteLoader = fileRoute.FileRouteLoader;
216
217
  exports.LazyRoute = fileRoute.LazyRoute;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -5,7 +5,7 @@ export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryStat
5
5
  export { useAwaited, Await } from './awaited.cjs';
6
6
  export type { AwaitOptions } from './awaited.cjs';
7
7
  export { CatchBoundary, ErrorComponent } from './CatchBoundary.cjs';
8
- export { ClientOnly } from './ClientOnly.cjs';
8
+ export { ClientOnly, useHydrated } from './ClientOnly.cjs';
9
9
  export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.cjs';
10
10
  export * from './history.cjs';
11
11
  export { lazyRouteComponent } from './lazyRouteComponent.cjs';
@@ -32,3 +32,26 @@ export interface ClientOnlyProps {
32
32
  * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent
33
33
  */
34
34
  export declare function ClientOnly({ children, fallback }: ClientOnlyProps): import("react/jsx-runtime").JSX.Element;
35
+ /**
36
+ * Return a boolean indicating if the JS has been hydrated already.
37
+ * When doing Server-Side Rendering, the result will always be false.
38
+ * When doing Client-Side Rendering, the result will always be false on the
39
+ * first render and true from then on. Even if a new component renders it will
40
+ * always start with true.
41
+ *
42
+ * @example
43
+ * ```tsx
44
+ * // Disable a button that needs JS to work.
45
+ * let hydrated = useHydrated()
46
+ * return (
47
+ * <button type="button" disabled={!hydrated} onClick={doSomethingCustom}>
48
+ * Click me
49
+ * </button>
50
+ * )
51
+ * ```
52
+ * @returns True if the JS has been hydrated already, false otherwise.
53
+ */
54
+ /**
55
+ * Return a boolean indicating whether client hydration has occurred.
56
+ */
57
+ export declare function useHydrated(): boolean;
@@ -15,6 +15,7 @@ function subscribe() {
15
15
  };
16
16
  }
17
17
  export {
18
- ClientOnly
18
+ ClientOnly,
19
+ useHydrated
19
20
  };
20
21
  //# sourceMappingURL=ClientOnly.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClientOnly.js","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\n/**\n * Render children only after client hydration; otherwise render `fallback`.\n * Useful for components that require browser-only APIs.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\n/**\n * Return a boolean indicating whether client hydration has occurred.\n */\nfunction useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"names":["React"],"mappings":";;AAmCO,SAAS,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,SAAO,YAAA,IACL,oBAACA,eAAM,UAAN,EAAgB,SAAA,CAAS,IAE1B,oBAACA,eAAM,UAAN,EAAgB,UAAA,SAAA,CAAS;AAE9B;AAwBA,SAAS,cAAuB;AAC9B,SAAOA,eAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;"}
1
+ {"version":3,"file":"ClientOnly.js","sources":["../../src/ClientOnly.tsx"],"sourcesContent":["import React from 'react'\n\nexport interface ClientOnlyProps {\n /**\n * The children to render when the JS is loaded.\n */\n children: React.ReactNode\n /**\n * The fallback component to render if the JS is not yet loaded.\n */\n fallback?: React.ReactNode\n}\n\n/**\n * Render the children only after the JS has loaded client-side. Use an optional\n * fallback component if the JS is not yet loaded.\n *\n * @example\n * Render a Chart component if JS loads, renders a simple FakeChart\n * component server-side or if there is no JS. The FakeChart can have only the\n * UI without the behavior or be a loading spinner or skeleton.\n *\n * ```tsx\n * return (\n * <ClientOnly fallback={<FakeChart />}>\n * <Chart />\n * </ClientOnly>\n * )\n * ```\n */\n/**\n * Render children only after client hydration; otherwise render `fallback`.\n * Useful for components that require browser-only APIs.\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/clientOnlyComponent\n */\nexport function ClientOnly({ children, fallback = null }: ClientOnlyProps) {\n return useHydrated() ? (\n <React.Fragment>{children}</React.Fragment>\n ) : (\n <React.Fragment>{fallback}</React.Fragment>\n )\n}\n\n/**\n * Return a boolean indicating if the JS has been hydrated already.\n * When doing Server-Side Rendering, the result will always be false.\n * When doing Client-Side Rendering, the result will always be false on the\n * first render and true from then on. Even if a new component renders it will\n * always start with true.\n *\n * @example\n * ```tsx\n * // Disable a button that needs JS to work.\n * let hydrated = useHydrated()\n * return (\n * <button type=\"button\" disabled={!hydrated} onClick={doSomethingCustom}>\n * Click me\n * </button>\n * )\n * ```\n * @returns True if the JS has been hydrated already, false otherwise.\n */\n/**\n * Return a boolean indicating whether client hydration has occurred.\n */\nexport function useHydrated(): boolean {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n )\n}\n\nfunction subscribe() {\n return () => {}\n}\n"],"names":["React"],"mappings":";;AAmCO,SAAS,WAAW,EAAE,UAAU,WAAW,QAAyB;AACzE,SAAO,YAAA,IACL,oBAACA,eAAM,UAAN,EAAgB,SAAA,CAAS,IAE1B,oBAACA,eAAM,UAAN,EAAgB,UAAA,SAAA,CAAS;AAE9B;AAwBO,SAAS,cAAuB;AACrC,SAAOA,eAAM;AAAA,IACX;AAAA,IACA,MAAM;AAAA,IACN,MAAM;AAAA,EAAA;AAEV;AAEA,SAAS,YAAY;AACnB,SAAO,MAAM;AAAA,EAAC;AAChB;"}
@@ -5,7 +5,7 @@ export type { BlockerFn, HistoryLocation, RouterHistory, ParsedPath, HistoryStat
5
5
  export { useAwaited, Await } from './awaited.js';
6
6
  export type { AwaitOptions } from './awaited.js';
7
7
  export { CatchBoundary, ErrorComponent } from './CatchBoundary.js';
8
- export { ClientOnly } from './ClientOnly.js';
8
+ export { ClientOnly, useHydrated } from './ClientOnly.js';
9
9
  export { FileRoute, createFileRoute, FileRouteLoader, LazyRoute, createLazyRoute, createLazyFileRoute, } from './fileRoute.js';
10
10
  export * from './history.js';
11
11
  export { lazyRouteComponent } from './lazyRouteComponent.js';
package/dist/esm/index.js CHANGED
@@ -2,7 +2,7 @@ import { PathParamError, SearchParamError, TSR_DEFERRED_PROMISE, cleanPath, comp
2
2
  import { createBrowserHistory, createHashHistory, createHistory, createMemoryHistory } from "@tanstack/history";
3
3
  import { Await, useAwaited } from "./awaited.js";
4
4
  import { CatchBoundary, ErrorComponent } from "./CatchBoundary.js";
5
- import { ClientOnly } from "./ClientOnly.js";
5
+ import { ClientOnly, useHydrated } from "./ClientOnly.js";
6
6
  import { FileRoute, FileRouteLoader, LazyRoute, createFileRoute, createLazyFileRoute, createLazyRoute } from "./fileRoute.js";
7
7
  import { lazyRouteComponent } from "./lazyRouteComponent.js";
8
8
  import { Link, createLink, linkOptions, useLinkProps } from "./link.js";
@@ -124,6 +124,7 @@ export {
124
124
  useCanGoBack,
125
125
  useChildMatches,
126
126
  useElementScrollRestoration,
127
+ useHydrated,
127
128
  useLayoutEffect,
128
129
  useLinkProps,
129
130
  useLoaderData,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/react-router",
3
- "version": "1.134.18",
3
+ "version": "1.135.0",
4
4
  "description": "Modern and scalable routing for React applications",
5
5
  "author": "Tanner Linsley",
6
6
  "license": "MIT",
@@ -80,7 +80,7 @@
80
80
  "tiny-invariant": "^1.3.3",
81
81
  "tiny-warning": "^1.0.3",
82
82
  "@tanstack/history": "1.133.28",
83
- "@tanstack/router-core": "1.134.18"
83
+ "@tanstack/router-core": "1.134.20"
84
84
  },
85
85
  "devDependencies": {
86
86
  "@testing-library/jest-dom": "^6.6.3",
@@ -63,7 +63,7 @@ export function ClientOnly({ children, fallback = null }: ClientOnlyProps) {
63
63
  /**
64
64
  * Return a boolean indicating whether client hydration has occurred.
65
65
  */
66
- function useHydrated(): boolean {
66
+ export function useHydrated(): boolean {
67
67
  return React.useSyncExternalStore(
68
68
  subscribe,
69
69
  () => true,
package/src/index.tsx CHANGED
@@ -130,7 +130,7 @@ export { useAwaited, Await } from './awaited'
130
130
  export type { AwaitOptions } from './awaited'
131
131
 
132
132
  export { CatchBoundary, ErrorComponent } from './CatchBoundary'
133
- export { ClientOnly } from './ClientOnly'
133
+ export { ClientOnly, useHydrated } from './ClientOnly'
134
134
 
135
135
  export {
136
136
  FileRoute,