react-router 7.8.1 → 7.8.2-pre.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/development/{chunk-UH6JLGW7.mjs → chunk-5LNVHL6T.mjs} +185 -201
  3. package/dist/development/{chunk-TGXCWGPT.js → chunk-KUJAVZYD.js} +123 -180
  4. package/dist/development/{chunk-IFMMFE4R.mjs → chunk-RVSOEW4N.mjs} +34 -75
  5. package/dist/development/{chunk-IIA3TUI2.js → chunk-UMVNFWBW.js} +210 -169
  6. package/dist/development/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
  7. package/dist/development/dom-export.d.mts +20 -2
  8. package/dist/development/dom-export.d.ts +20 -1
  9. package/dist/development/dom-export.js +10 -4
  10. package/dist/development/dom-export.mjs +10 -4
  11. package/dist/{production/index-react-server-client-BQ6FxdA_.d.ts → development/index-react-server-client-C4AMmMi3.d.ts} +6 -816
  12. package/dist/{production/index-react-server-client-11fLy3qB.d.mts → development/index-react-server-client-DgVbd8DS.d.mts} +2 -3
  13. package/dist/development/index-react-server-client.d.mts +3 -4
  14. package/dist/development/index-react-server-client.d.ts +2 -2
  15. package/dist/development/index-react-server-client.js +4 -4
  16. package/dist/development/index-react-server-client.mjs +2 -2
  17. package/dist/development/index-react-server.d.mts +1 -1
  18. package/dist/development/index-react-server.d.ts +1 -1
  19. package/dist/development/index-react-server.js +39 -45
  20. package/dist/development/index-react-server.mjs +39 -45
  21. package/dist/development/index.d.mts +7 -9
  22. package/dist/development/index.d.ts +5 -5
  23. package/dist/development/index.js +122 -163
  24. package/dist/development/index.mjs +3 -3
  25. package/dist/development/lib/types/internal.d.mts +3 -3
  26. package/dist/development/lib/types/internal.d.ts +2 -2
  27. package/dist/development/lib/types/internal.js +1 -1
  28. package/dist/development/lib/types/internal.mjs +1 -1
  29. package/dist/development/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
  30. package/dist/development/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
  31. package/dist/production/{chunk-YMYXECPK.js → chunk-3PSRBVDP.js} +210 -169
  32. package/dist/production/{chunk-5Y7ELDIJ.mjs → chunk-4HHN5NDL.mjs} +34 -75
  33. package/dist/production/{chunk-KHPQXKYM.js → chunk-NCRSBAFG.js} +123 -180
  34. package/dist/production/{chunk-PFDCNQUK.mjs → chunk-O46NJYOA.mjs} +185 -201
  35. package/dist/production/{context-DohQKLID.d.mts → context-D5hQ2yCL.d.mts} +843 -6
  36. package/dist/production/dom-export.d.mts +20 -2
  37. package/dist/production/dom-export.d.ts +20 -1
  38. package/dist/production/dom-export.js +10 -4
  39. package/dist/production/dom-export.mjs +10 -4
  40. package/dist/{development/index-react-server-client-BQ6FxdA_.d.ts → production/index-react-server-client-C4AMmMi3.d.ts} +6 -816
  41. package/dist/{development/index-react-server-client-11fLy3qB.d.mts → production/index-react-server-client-DgVbd8DS.d.mts} +2 -3
  42. package/dist/production/index-react-server-client.d.mts +3 -4
  43. package/dist/production/index-react-server-client.d.ts +2 -2
  44. package/dist/production/index-react-server-client.js +4 -4
  45. package/dist/production/index-react-server-client.mjs +2 -2
  46. package/dist/production/index-react-server.d.mts +1 -1
  47. package/dist/production/index-react-server.d.ts +1 -1
  48. package/dist/production/index-react-server.js +39 -45
  49. package/dist/production/index-react-server.mjs +39 -45
  50. package/dist/production/index.d.mts +7 -9
  51. package/dist/production/index.d.ts +5 -5
  52. package/dist/production/index.js +122 -163
  53. package/dist/production/index.mjs +3 -3
  54. package/dist/production/lib/types/internal.d.mts +3 -3
  55. package/dist/production/lib/types/internal.d.ts +2 -2
  56. package/dist/production/lib/types/internal.js +1 -1
  57. package/dist/production/lib/types/internal.mjs +1 -1
  58. package/dist/production/{route-data-CNjObrhZ.d.mts → route-data-B3sNokxM.d.mts} +2 -2
  59. package/dist/production/{routeModules-C3oqzPpI.d.ts → routeModules-DRWHoPcT.d.ts} +844 -7
  60. package/package.json +1 -1
  61. package/dist/development/components-CuPfnyiZ.d.mts +0 -814
  62. package/dist/production/components-CuPfnyiZ.d.mts +0 -814
@@ -1037,7 +1037,7 @@ declare function isRouteErrorResponse(error: any): error is ErrorResponse;
1037
1037
  /**
1038
1038
  * A Router instance manages all navigation and data loading/mutations
1039
1039
  */
1040
- interface Router {
1040
+ interface Router$1 {
1041
1041
  /**
1042
1042
  * @private
1043
1043
  * PRIVATE - DO NOT USE
@@ -1081,7 +1081,7 @@ interface Router {
1081
1081
  * initial data fetches. Returns a function to cleanup listeners and abort
1082
1082
  * any in-progress loads
1083
1083
  */
1084
- initialize(): Router;
1084
+ initialize(): Router$1;
1085
1085
  /**
1086
1086
  * @private
1087
1087
  * PRIVATE - DO NOT USE
@@ -1321,7 +1321,7 @@ interface RouterInit {
1321
1321
  * State returned from a server-side query() call
1322
1322
  */
1323
1323
  interface StaticHandlerContext {
1324
- basename: Router["basename"];
1324
+ basename: Router$1["basename"];
1325
1325
  location: RouterState["location"];
1326
1326
  matches: RouterState["matches"];
1327
1327
  loaderData: RouterState["loaderData"];
@@ -1576,13 +1576,849 @@ declare const IDLE_BLOCKER: BlockerUnblocked;
1576
1576
  /**
1577
1577
  * Create a router and listen to history POP navigations
1578
1578
  */
1579
- declare function createRouter(init: RouterInit): Router;
1579
+ declare function createRouter(init: RouterInit): Router$1;
1580
1580
  interface CreateStaticHandlerOptions {
1581
1581
  basename?: string;
1582
1582
  mapRouteProperties?: MapRoutePropertiesFunction;
1583
1583
  future?: {};
1584
1584
  }
1585
1585
 
1586
+ declare function mapRouteProperties(route: RouteObject): Partial<RouteObject> & {
1587
+ hasErrorBoundary: boolean;
1588
+ };
1589
+ declare const hydrationRouteProperties: (keyof RouteObject)[];
1590
+ /**
1591
+ * @category Data Routers
1592
+ */
1593
+ interface MemoryRouterOpts {
1594
+ /**
1595
+ * Basename path for the application.
1596
+ */
1597
+ basename?: string;
1598
+ /**
1599
+ * A function that returns an {@link unstable_RouterContextProvider} instance
1600
+ * which is provided as the `context` argument to client [`action`](../../start/data/route-object#action)s,
1601
+ * [`loader`](../../start/data/route-object#loader)s and [middleware](../../how-to/middleware).
1602
+ * This function is called to generate a fresh `context` instance on each
1603
+ * navigation or fetcher call.
1604
+ */
1605
+ unstable_getContext?: RouterInit["unstable_getContext"];
1606
+ /**
1607
+ * Future flags to enable for the router.
1608
+ */
1609
+ future?: Partial<FutureConfig>;
1610
+ /**
1611
+ * Hydration data to initialize the router with if you have already performed
1612
+ * data loading on the server.
1613
+ */
1614
+ hydrationData?: HydrationState;
1615
+ /**
1616
+ * Initial entries in the in-memory history stack
1617
+ */
1618
+ initialEntries?: InitialEntry[];
1619
+ /**
1620
+ * Index of `initialEntries` the application should initialize to
1621
+ */
1622
+ initialIndex?: number;
1623
+ /**
1624
+ * Override the default data strategy of loading in parallel.
1625
+ * Only intended for advanced usage.
1626
+ */
1627
+ dataStrategy?: DataStrategyFunction;
1628
+ /**
1629
+ * Lazily define portions of the route tree on navigations.
1630
+ */
1631
+ patchRoutesOnNavigation?: PatchRoutesOnNavigationFunction;
1632
+ }
1633
+ /**
1634
+ * Create a new {@link DataRouter} that manages the application path using an
1635
+ * in-memory [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1636
+ * stack. Useful for non-browser environments without a DOM API.
1637
+ *
1638
+ * @public
1639
+ * @category Data Routers
1640
+ * @mode data
1641
+ * @param routes Application routes
1642
+ * @param opts Options
1643
+ * @param {MemoryRouterOpts.basename} opts.basename n/a
1644
+ * @param {MemoryRouterOpts.dataStrategy} opts.dataStrategy n/a
1645
+ * @param {MemoryRouterOpts.future} opts.future n/a
1646
+ * @param {MemoryRouterOpts.unstable_getContext} opts.unstable_getContext n/a
1647
+ * @param {MemoryRouterOpts.hydrationData} opts.hydrationData n/a
1648
+ * @param {MemoryRouterOpts.initialEntries} opts.initialEntries n/a
1649
+ * @param {MemoryRouterOpts.initialIndex} opts.initialIndex n/a
1650
+ * @param {MemoryRouterOpts.patchRoutesOnNavigation} opts.patchRoutesOnNavigation n/a
1651
+ * @returns An initialized {@link DataRouter} to pass to {@link RouterProvider | `<RouterProvider>`}
1652
+ */
1653
+ declare function createMemoryRouter(routes: RouteObject[], opts?: MemoryRouterOpts): Router$1;
1654
+ /**
1655
+ * Function signature for client side error handling for loader/actions errors
1656
+ * and rendering errors via `componentDidCatch`
1657
+ */
1658
+ interface unstable_ClientOnErrorFunction {
1659
+ (error: unknown, errorInfo?: React.ErrorInfo): void;
1660
+ }
1661
+ /**
1662
+ * @category Types
1663
+ */
1664
+ interface RouterProviderProps {
1665
+ /**
1666
+ * The {@link DataRouter} instance to use for navigation and data fetching.
1667
+ */
1668
+ router: Router$1;
1669
+ /**
1670
+ * The [`ReactDOM.flushSync`](https://react.dev/reference/react-dom/flushSync)
1671
+ * implementation to use for flushing updates.
1672
+ *
1673
+ * You usually don't have to worry about this:
1674
+ * - The `RouterProvider` exported from `react-router/dom` handles this internally for you
1675
+ * - If you are rendering in a non-DOM environment, you can import
1676
+ * `RouterProvider` from `react-router` and ignore this prop
1677
+ */
1678
+ flushSync?: (fn: () => unknown) => undefined;
1679
+ /**
1680
+ * An error handler function that will be called for any loader/action/render
1681
+ * errors that are encountered in your application. This is useful for
1682
+ * logging or reporting errors instead of the `ErrorBoundary` because it's not
1683
+ * subject to re-rendering and will only run one time per error.
1684
+ *
1685
+ * The `errorInfo` parameter is passed along from
1686
+ * [`componentDidCatch`](https://react.dev/reference/react/Component#componentdidcatch)
1687
+ * and is only present for render errors.
1688
+ *
1689
+ * ```tsx
1690
+ * <RouterProvider unstable_onError=(error, errorInfo) => {
1691
+ * console.error(error, errorInfo);
1692
+ * reportToErrorService(error, errorInfo);
1693
+ * }} />
1694
+ * ```
1695
+ */
1696
+ unstable_onError?: unstable_ClientOnErrorFunction;
1697
+ }
1698
+ /**
1699
+ * Render the UI for the given {@link DataRouter}. This component should
1700
+ * typically be at the top of an app's element tree.
1701
+ *
1702
+ * ```tsx
1703
+ * import { createBrowserRouter } from "react-router";
1704
+ * import { RouterProvider } from "react-router/dom";
1705
+ * import { createRoot } from "react-dom/client";
1706
+ *
1707
+ * const router = createBrowserRouter(routes);
1708
+ * createRoot(document.getElementById("root")).render(
1709
+ * <RouterProvider router={router} />
1710
+ * );
1711
+ * ```
1712
+ *
1713
+ * <docs-info>Please note that this component is exported both from
1714
+ * `react-router` and `react-router/dom` with the only difference being that the
1715
+ * latter automatically wires up `react-dom`'s [`flushSync`](https://react.dev/reference/react-dom/flushSync)
1716
+ * implementation. You _almost always_ want to use the version from
1717
+ * `react-router/dom` unless you're running in a non-DOM environment.</docs-info>
1718
+ *
1719
+ *
1720
+ * @public
1721
+ * @category Data Routers
1722
+ * @mode data
1723
+ * @param props Props
1724
+ * @param {RouterProviderProps.flushSync} props.flushSync n/a
1725
+ * @param {RouterProviderProps.unstable_onError} props.unstable_onError n/a
1726
+ * @param {RouterProviderProps.router} props.router n/a
1727
+ * @returns React element for the rendered router
1728
+ */
1729
+ declare function RouterProvider({ router, flushSync: reactDomFlushSyncImpl, unstable_onError, }: RouterProviderProps): React.ReactElement;
1730
+ /**
1731
+ * @category Types
1732
+ */
1733
+ interface MemoryRouterProps {
1734
+ /**
1735
+ * Application basename
1736
+ */
1737
+ basename?: string;
1738
+ /**
1739
+ * Nested {@link Route} elements describing the route tree
1740
+ */
1741
+ children?: React.ReactNode;
1742
+ /**
1743
+ * Initial entries in the in-memory history stack
1744
+ */
1745
+ initialEntries?: InitialEntry[];
1746
+ /**
1747
+ * Index of `initialEntries` the application should initialize to
1748
+ */
1749
+ initialIndex?: number;
1750
+ }
1751
+ /**
1752
+ * A declarative {@link Router | `<Router>`} that stores all entries in memory.
1753
+ *
1754
+ * @public
1755
+ * @category Declarative Routers
1756
+ * @mode declarative
1757
+ * @param props Props
1758
+ * @param {MemoryRouterProps.basename} props.basename n/a
1759
+ * @param {MemoryRouterProps.children} props.children n/a
1760
+ * @param {MemoryRouterProps.initialEntries} props.initialEntries n/a
1761
+ * @param {MemoryRouterProps.initialIndex} props.initialIndex n/a
1762
+ * @returns A declarative in-memory {@link Router | `<Router>`} for client-side
1763
+ * routing.
1764
+ */
1765
+ declare function MemoryRouter({ basename, children, initialEntries, initialIndex, }: MemoryRouterProps): React.ReactElement;
1766
+ /**
1767
+ * @category Types
1768
+ */
1769
+ interface NavigateProps {
1770
+ /**
1771
+ * The path to navigate to. This can be a string or a {@link Path} object
1772
+ */
1773
+ to: To;
1774
+ /**
1775
+ * Whether to replace the current entry in the [`History`](https://developer.mozilla.org/en-US/docs/Web/API/History)
1776
+ * stack
1777
+ */
1778
+ replace?: boolean;
1779
+ /**
1780
+ * State to pass to the new {@link Location} to store in [`history.state`](https://developer.mozilla.org/en-US/docs/Web/API/History/state).
1781
+ */
1782
+ state?: any;
1783
+ /**
1784
+ * How to interpret relative routing in the `to` prop.
1785
+ * See {@link RelativeRoutingType}.
1786
+ */
1787
+ relative?: RelativeRoutingType;
1788
+ }
1789
+ /**
1790
+ * A component-based version of {@link useNavigate} to use in a
1791
+ * [`React.Component` class](https://react.dev/reference/react/Component) where
1792
+ * hooks cannot be used.
1793
+ *
1794
+ * It's recommended to avoid using this component in favor of {@link useNavigate}.
1795
+ *
1796
+ * @example
1797
+ * <Navigate to="/tasks" />
1798
+ *
1799
+ * @public
1800
+ * @category Components
1801
+ * @param props Props
1802
+ * @param {NavigateProps.relative} props.relative n/a
1803
+ * @param {NavigateProps.replace} props.replace n/a
1804
+ * @param {NavigateProps.state} props.state n/a
1805
+ * @param {NavigateProps.to} props.to n/a
1806
+ * @returns {void}
1807
+ *
1808
+ */
1809
+ declare function Navigate({ to, replace, state, relative, }: NavigateProps): null;
1810
+ /**
1811
+ * @category Types
1812
+ */
1813
+ interface OutletProps {
1814
+ /**
1815
+ * Provides a context value to the element tree below the outlet. Use when
1816
+ * the parent route needs to provide values to child routes.
1817
+ *
1818
+ * ```tsx
1819
+ * <Outlet context={myContextValue} />
1820
+ * ```
1821
+ *
1822
+ * Access the context with {@link useOutletContext}.
1823
+ */
1824
+ context?: unknown;
1825
+ }
1826
+ /**
1827
+ * Renders the matching child route of a parent route or nothing if no child
1828
+ * route matches.
1829
+ *
1830
+ * @example
1831
+ * import { Outlet } from "react-router";
1832
+ *
1833
+ * export default function SomeParent() {
1834
+ * return (
1835
+ * <div>
1836
+ * <h1>Parent Content</h1>
1837
+ * <Outlet />
1838
+ * </div>
1839
+ * );
1840
+ * }
1841
+ *
1842
+ * @public
1843
+ * @category Components
1844
+ * @param props Props
1845
+ * @param {OutletProps.context} props.context n/a
1846
+ * @returns React element for the rendered outlet or `null` if no child route matches.
1847
+ */
1848
+ declare function Outlet(props: OutletProps): React.ReactElement | null;
1849
+ /**
1850
+ * @category Types
1851
+ */
1852
+ interface PathRouteProps {
1853
+ /**
1854
+ * Whether the path should be case-sensitive. Defaults to `false`.
1855
+ */
1856
+ caseSensitive?: NonIndexRouteObject["caseSensitive"];
1857
+ /**
1858
+ * The path pattern to match. If unspecified or empty, then this becomes a
1859
+ * layout route.
1860
+ */
1861
+ path?: NonIndexRouteObject["path"];
1862
+ /**
1863
+ * The unique identifier for this route (for use with {@link DataRouter}s)
1864
+ */
1865
+ id?: NonIndexRouteObject["id"];
1866
+ /**
1867
+ * A function that returns a promise that resolves to the route object.
1868
+ * Used for code-splitting routes.
1869
+ * See [`lazy`](../../start/data/route-object#lazy).
1870
+ */
1871
+ lazy?: LazyRouteFunction<NonIndexRouteObject>;
1872
+ /**
1873
+ * The route loader.
1874
+ * See [`loader`](../../start/data/route-object#loader).
1875
+ */
1876
+ loader?: NonIndexRouteObject["loader"];
1877
+ /**
1878
+ * The route action.
1879
+ * See [`action`](../../start/data/route-object#action).
1880
+ */
1881
+ action?: NonIndexRouteObject["action"];
1882
+ hasErrorBoundary?: NonIndexRouteObject["hasErrorBoundary"];
1883
+ /**
1884
+ * The route shouldRevalidate function.
1885
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1886
+ */
1887
+ shouldRevalidate?: NonIndexRouteObject["shouldRevalidate"];
1888
+ /**
1889
+ * The route handle.
1890
+ */
1891
+ handle?: NonIndexRouteObject["handle"];
1892
+ /**
1893
+ * Whether this is an index route.
1894
+ */
1895
+ index?: false;
1896
+ /**
1897
+ * Child Route components
1898
+ */
1899
+ children?: React.ReactNode;
1900
+ /**
1901
+ * The React element to render when this Route matches.
1902
+ * Mutually exclusive with `Component`.
1903
+ */
1904
+ element?: React.ReactNode | null;
1905
+ /**
1906
+ * The React element to render while this router is loading data.
1907
+ * Mutually exclusive with `HydrateFallback`.
1908
+ */
1909
+ hydrateFallbackElement?: React.ReactNode | null;
1910
+ /**
1911
+ * The React element to render at this route if an error occurs.
1912
+ * Mutually exclusive with `ErrorBoundary`.
1913
+ */
1914
+ errorElement?: React.ReactNode | null;
1915
+ /**
1916
+ * The React Component to render when this route matches.
1917
+ * Mutually exclusive with `element`.
1918
+ */
1919
+ Component?: React.ComponentType | null;
1920
+ /**
1921
+ * The React Component to render while this router is loading data.
1922
+ * Mutually exclusive with `hydrateFallbackElement`.
1923
+ */
1924
+ HydrateFallback?: React.ComponentType | null;
1925
+ /**
1926
+ * The React Component to render at this route if an error occurs.
1927
+ * Mutually exclusive with `errorElement`.
1928
+ */
1929
+ ErrorBoundary?: React.ComponentType | null;
1930
+ }
1931
+ /**
1932
+ * @category Types
1933
+ */
1934
+ interface LayoutRouteProps extends PathRouteProps {
1935
+ }
1936
+ /**
1937
+ * @category Types
1938
+ */
1939
+ interface IndexRouteProps {
1940
+ /**
1941
+ * Whether the path should be case-sensitive. Defaults to `false`.
1942
+ */
1943
+ caseSensitive?: IndexRouteObject["caseSensitive"];
1944
+ /**
1945
+ * The path pattern to match. If unspecified or empty, then this becomes a
1946
+ * layout route.
1947
+ */
1948
+ path?: IndexRouteObject["path"];
1949
+ /**
1950
+ * The unique identifier for this route (for use with {@link DataRouter}s)
1951
+ */
1952
+ id?: IndexRouteObject["id"];
1953
+ /**
1954
+ * A function that returns a promise that resolves to the route object.
1955
+ * Used for code-splitting routes.
1956
+ * See [`lazy`](../../start/data/route-object#lazy).
1957
+ */
1958
+ lazy?: LazyRouteFunction<IndexRouteObject>;
1959
+ /**
1960
+ * The route loader.
1961
+ * See [`loader`](../../start/data/route-object#loader).
1962
+ */
1963
+ loader?: IndexRouteObject["loader"];
1964
+ /**
1965
+ * The route action.
1966
+ * See [`action`](../../start/data/route-object#action).
1967
+ */
1968
+ action?: IndexRouteObject["action"];
1969
+ hasErrorBoundary?: IndexRouteObject["hasErrorBoundary"];
1970
+ /**
1971
+ * The route shouldRevalidate function.
1972
+ * See [`shouldRevalidate`](../../start/data/route-object#shouldRevalidate).
1973
+ */
1974
+ shouldRevalidate?: IndexRouteObject["shouldRevalidate"];
1975
+ /**
1976
+ * The route handle.
1977
+ */
1978
+ handle?: IndexRouteObject["handle"];
1979
+ /**
1980
+ * Whether this is an index route.
1981
+ */
1982
+ index: true;
1983
+ /**
1984
+ * Child Route components
1985
+ */
1986
+ children?: undefined;
1987
+ /**
1988
+ * The React element to render when this Route matches.
1989
+ * Mutually exclusive with `Component`.
1990
+ */
1991
+ element?: React.ReactNode | null;
1992
+ /**
1993
+ * The React element to render while this router is loading data.
1994
+ * Mutually exclusive with `HydrateFallback`.
1995
+ */
1996
+ hydrateFallbackElement?: React.ReactNode | null;
1997
+ /**
1998
+ * The React element to render at this route if an error occurs.
1999
+ * Mutually exclusive with `ErrorBoundary`.
2000
+ */
2001
+ errorElement?: React.ReactNode | null;
2002
+ /**
2003
+ * The React Component to render when this route matches.
2004
+ * Mutually exclusive with `element`.
2005
+ */
2006
+ Component?: React.ComponentType | null;
2007
+ /**
2008
+ * The React Component to render while this router is loading data.
2009
+ * Mutually exclusive with `hydrateFallbackElement`.
2010
+ */
2011
+ HydrateFallback?: React.ComponentType | null;
2012
+ /**
2013
+ * The React Component to render at this route if an error occurs.
2014
+ * Mutually exclusive with `errorElement`.
2015
+ */
2016
+ ErrorBoundary?: React.ComponentType | null;
2017
+ }
2018
+ type RouteProps = PathRouteProps | LayoutRouteProps | IndexRouteProps;
2019
+ /**
2020
+ * Configures an element to render when a pattern matches the current location.
2021
+ * It must be rendered within a {@link Routes} element. Note that these routes
2022
+ * do not participate in data loading, actions, code splitting, or any other
2023
+ * route module features.
2024
+ *
2025
+ * @example
2026
+ * // Usually used in a declarative router
2027
+ * function App() {
2028
+ * return (
2029
+ * <BrowserRouter>
2030
+ * <Routes>
2031
+ * <Route index element={<StepOne />} />
2032
+ * <Route path="step-2" element={<StepTwo />} />
2033
+ * <Route path="step-3" element={<StepThree />} />
2034
+ * </Routes>
2035
+ * </BrowserRouter>
2036
+ * );
2037
+ * }
2038
+ *
2039
+ * // But can be used with a data router as well if you prefer the JSX notation
2040
+ * const routes = createRoutesFromElements(
2041
+ * <>
2042
+ * <Route index loader={step1Loader} Component={StepOne} />
2043
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
2044
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
2045
+ * </>
2046
+ * );
2047
+ *
2048
+ * const router = createBrowserRouter(routes);
2049
+ *
2050
+ * function App() {
2051
+ * return <RouterProvider router={router} />;
2052
+ * }
2053
+ *
2054
+ * @public
2055
+ * @category Components
2056
+ * @param props Props
2057
+ * @param {PathRouteProps.action} props.action n/a
2058
+ * @param {PathRouteProps.caseSensitive} props.caseSensitive n/a
2059
+ * @param {PathRouteProps.Component} props.Component n/a
2060
+ * @param {PathRouteProps.children} props.children n/a
2061
+ * @param {PathRouteProps.element} props.element n/a
2062
+ * @param {PathRouteProps.ErrorBoundary} props.ErrorBoundary n/a
2063
+ * @param {PathRouteProps.errorElement} props.errorElement n/a
2064
+ * @param {PathRouteProps.handle} props.handle n/a
2065
+ * @param {PathRouteProps.HydrateFallback} props.HydrateFallback n/a
2066
+ * @param {PathRouteProps.hydrateFallbackElement} props.hydrateFallbackElement n/a
2067
+ * @param {PathRouteProps.id} props.id n/a
2068
+ * @param {PathRouteProps.index} props.index n/a
2069
+ * @param {PathRouteProps.lazy} props.lazy n/a
2070
+ * @param {PathRouteProps.loader} props.loader n/a
2071
+ * @param {PathRouteProps.path} props.path n/a
2072
+ * @param {PathRouteProps.shouldRevalidate} props.shouldRevalidate n/a
2073
+ * @returns {void}
2074
+ */
2075
+ declare function Route(props: RouteProps): React.ReactElement | null;
2076
+ /**
2077
+ * @category Types
2078
+ */
2079
+ interface RouterProps {
2080
+ /**
2081
+ * The base path for the application. This is prepended to all locations
2082
+ */
2083
+ basename?: string;
2084
+ /**
2085
+ * Nested {@link Route} elements describing the route tree
2086
+ */
2087
+ children?: React.ReactNode;
2088
+ /**
2089
+ * The location to match against. Defaults to the current location.
2090
+ * This can be a string or a {@link Location} object.
2091
+ */
2092
+ location: Partial<Location> | string;
2093
+ /**
2094
+ * The type of navigation that triggered this `location` change.
2095
+ * Defaults to {@link NavigationType.Pop}.
2096
+ */
2097
+ navigationType?: Action;
2098
+ /**
2099
+ * The navigator to use for navigation. This is usually a history object
2100
+ * or a custom navigator that implements the {@link Navigator} interface.
2101
+ */
2102
+ navigator: Navigator;
2103
+ /**
2104
+ * Whether this router is static or not (used for SSR). If `true`, the router
2105
+ * will not be reactive to location changes.
2106
+ */
2107
+ static?: boolean;
2108
+ }
2109
+ /**
2110
+ * Provides location context for the rest of the app.
2111
+ *
2112
+ * Note: You usually won't render a `<Router>` directly. Instead, you'll render a
2113
+ * router that is more specific to your environment such as a {@link BrowserRouter}
2114
+ * in web browsers or a {@link ServerRouter} for server rendering.
2115
+ *
2116
+ * @public
2117
+ * @category Declarative Routers
2118
+ * @mode declarative
2119
+ * @param props Props
2120
+ * @param {RouterProps.basename} props.basename n/a
2121
+ * @param {RouterProps.children} props.children n/a
2122
+ * @param {RouterProps.location} props.location n/a
2123
+ * @param {RouterProps.navigationType} props.navigationType n/a
2124
+ * @param {RouterProps.navigator} props.navigator n/a
2125
+ * @param {RouterProps.static} props.static n/a
2126
+ * @returns React element for the rendered router or `null` if the location does
2127
+ * not match the {@link props.basename}
2128
+ */
2129
+ declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
2130
+ /**
2131
+ * @category Types
2132
+ */
2133
+ interface RoutesProps {
2134
+ /**
2135
+ * Nested {@link Route} elements
2136
+ */
2137
+ children?: React.ReactNode;
2138
+ /**
2139
+ * The {@link Location} to match against. Defaults to the current location.
2140
+ */
2141
+ location?: Partial<Location> | string;
2142
+ }
2143
+ /**
2144
+ * Renders a branch of {@link Route | `<Route>`s} that best matches the current
2145
+ * location. Note that these routes do not participate in [data loading](../../start/framework/route-module#loader),
2146
+ * [`action`](../../start/framework/route-module#action), code splitting, or
2147
+ * any other [route module](../../start/framework/route-module) features.
2148
+ *
2149
+ * @example
2150
+ * import { Route, Routes } from "react-router";
2151
+ *
2152
+ * <Routes>
2153
+ * <Route index element={<StepOne />} />
2154
+ * <Route path="step-2" element={<StepTwo />} />
2155
+ * <Route path="step-3" element={<StepThree />}>
2156
+ * </Routes>
2157
+ *
2158
+ * @public
2159
+ * @category Components
2160
+ * @param props Props
2161
+ * @param {RoutesProps.children} props.children n/a
2162
+ * @param {RoutesProps.location} props.location n/a
2163
+ * @returns React element for the rendered routes or `null` if no route matches
2164
+ */
2165
+ declare function Routes({ children, location, }: RoutesProps): React.ReactElement | null;
2166
+ interface AwaitResolveRenderFunction<Resolve = any> {
2167
+ (data: Awaited<Resolve>): React.ReactNode;
2168
+ }
2169
+ /**
2170
+ * @category Types
2171
+ */
2172
+ interface AwaitProps<Resolve> {
2173
+ /**
2174
+ * When using a function, the resolved value is provided as the parameter.
2175
+ *
2176
+ * ```tsx [2]
2177
+ * <Await resolve={reviewsPromise}>
2178
+ * {(resolvedReviews) => <Reviews items={resolvedReviews} />}
2179
+ * </Await>
2180
+ * ```
2181
+ *
2182
+ * When using React elements, {@link useAsyncValue} will provide the
2183
+ * resolved value:
2184
+ *
2185
+ * ```tsx [2]
2186
+ * <Await resolve={reviewsPromise}>
2187
+ * <Reviews />
2188
+ * </Await>
2189
+ *
2190
+ * function Reviews() {
2191
+ * const resolvedReviews = useAsyncValue();
2192
+ * return <div>...</div>;
2193
+ * }
2194
+ * ```
2195
+ */
2196
+ children: React.ReactNode | AwaitResolveRenderFunction<Resolve>;
2197
+ /**
2198
+ * The error element renders instead of the `children` when the [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2199
+ * rejects.
2200
+ *
2201
+ * ```tsx
2202
+ * <Await
2203
+ * errorElement={<div>Oops</div>}
2204
+ * resolve={reviewsPromise}
2205
+ * >
2206
+ * <Reviews />
2207
+ * </Await>
2208
+ * ```
2209
+ *
2210
+ * To provide a more contextual error, you can use the {@link useAsyncError} in a
2211
+ * child component
2212
+ *
2213
+ * ```tsx
2214
+ * <Await
2215
+ * errorElement={<ReviewsError />}
2216
+ * resolve={reviewsPromise}
2217
+ * >
2218
+ * <Reviews />
2219
+ * </Await>
2220
+ *
2221
+ * function ReviewsError() {
2222
+ * const error = useAsyncError();
2223
+ * return <div>Error loading reviews: {error.message}</div>;
2224
+ * }
2225
+ * ```
2226
+ *
2227
+ * If you do not provide an `errorElement`, the rejected value will bubble up
2228
+ * to the nearest route-level [`ErrorBoundary`](../../start/framework/route-module#errorboundary)
2229
+ * and be accessible via the {@link useRouteError} hook.
2230
+ */
2231
+ errorElement?: React.ReactNode;
2232
+ /**
2233
+ * Takes a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
2234
+ * returned from a [`loader`](../../start/framework/route-module#loader) to be
2235
+ * resolved and rendered.
2236
+ *
2237
+ * ```tsx
2238
+ * import { Await, useLoaderData } from "react-router";
2239
+ *
2240
+ * export async function loader() {
2241
+ * let reviews = getReviews(); // not awaited
2242
+ * let book = await getBook();
2243
+ * return {
2244
+ * book,
2245
+ * reviews, // this is a promise
2246
+ * };
2247
+ * }
2248
+ *
2249
+ * export default function Book() {
2250
+ * const {
2251
+ * book,
2252
+ * reviews, // this is the same promise
2253
+ * } = useLoaderData();
2254
+ *
2255
+ * return (
2256
+ * <div>
2257
+ * <h1>{book.title}</h1>
2258
+ * <p>{book.description}</p>
2259
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
2260
+ * <Await
2261
+ * // and is the promise we pass to Await
2262
+ * resolve={reviews}
2263
+ * >
2264
+ * <Reviews />
2265
+ * </Await>
2266
+ * </React.Suspense>
2267
+ * </div>
2268
+ * );
2269
+ * }
2270
+ * ```
2271
+ */
2272
+ resolve: Resolve;
2273
+ }
2274
+ /**
2275
+ * Used to render promise values with automatic error handling.
2276
+ *
2277
+ * **Note:** `<Await>` expects to be rendered inside a [`<React.Suspense>`](https://react.dev/reference/react/Suspense)
2278
+ *
2279
+ * @example
2280
+ * import { Await, useLoaderData } from "react-router";
2281
+ *
2282
+ * export async function loader() {
2283
+ * // not awaited
2284
+ * const reviews = getReviews();
2285
+ * // awaited (blocks the transition)
2286
+ * const book = await fetch("/api/book").then((res) => res.json());
2287
+ * return { book, reviews };
2288
+ * }
2289
+ *
2290
+ * function Book() {
2291
+ * const { book, reviews } = useLoaderData();
2292
+ * return (
2293
+ * <div>
2294
+ * <h1>{book.title}</h1>
2295
+ * <p>{book.description}</p>
2296
+ * <React.Suspense fallback={<ReviewsSkeleton />}>
2297
+ * <Await
2298
+ * resolve={reviews}
2299
+ * errorElement={
2300
+ * <div>Could not load reviews 😬</div>
2301
+ * }
2302
+ * children={(resolvedReviews) => (
2303
+ * <Reviews items={resolvedReviews} />
2304
+ * )}
2305
+ * />
2306
+ * </React.Suspense>
2307
+ * </div>
2308
+ * );
2309
+ * }
2310
+ *
2311
+ * @public
2312
+ * @category Components
2313
+ * @mode framework
2314
+ * @mode data
2315
+ * @param props Props
2316
+ * @param {AwaitProps.children} props.children n/a
2317
+ * @param {AwaitProps.errorElement} props.errorElement n/a
2318
+ * @param {AwaitProps.resolve} props.resolve n/a
2319
+ * @returns React element for the rendered awaited value
2320
+ */
2321
+ declare function Await<Resolve>({ children, errorElement, resolve, }: AwaitProps<Resolve>): React.JSX.Element;
2322
+ /**
2323
+ * Creates a route config from a React "children" object, which is usually
2324
+ * either a `<Route>` element or an array of them. Used internally by
2325
+ * `<Routes>` to create a route config from its children.
2326
+ *
2327
+ * @category Utils
2328
+ * @mode data
2329
+ * @param children The React children to convert into a route config
2330
+ * @param parentPath The path of the parent route, used to generate unique IDs.
2331
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
2332
+ */
2333
+ declare function createRoutesFromChildren(children: React.ReactNode, parentPath?: number[]): RouteObject[];
2334
+ /**
2335
+ * Create route objects from JSX elements instead of arrays of objects.
2336
+ *
2337
+ * @example
2338
+ * const routes = createRoutesFromElements(
2339
+ * <>
2340
+ * <Route index loader={step1Loader} Component={StepOne} />
2341
+ * <Route path="step-2" loader={step2Loader} Component={StepTwo} />
2342
+ * <Route path="step-3" loader={step3Loader} Component={StepThree} />
2343
+ * </>
2344
+ * );
2345
+ *
2346
+ * const router = createBrowserRouter(routes);
2347
+ *
2348
+ * function App() {
2349
+ * return <RouterProvider router={router} />;
2350
+ * }
2351
+ *
2352
+ * @name createRoutesFromElements
2353
+ * @public
2354
+ * @category Utils
2355
+ * @mode data
2356
+ * @param children The React children to convert into a route config
2357
+ * @param parentPath The path of the parent route, used to generate unique IDs.
2358
+ * This is used for internal recursion and is not intended to be used by the
2359
+ * application developer.
2360
+ * @returns An array of {@link RouteObject}s that can be used with a {@link DataRouter}
2361
+ */
2362
+ declare const createRoutesFromElements: typeof createRoutesFromChildren;
2363
+ /**
2364
+ * Renders the result of {@link matchRoutes} into a React element.
2365
+ *
2366
+ * @public
2367
+ * @category Utils
2368
+ * @param matches The array of {@link RouteMatch | route matches} to render
2369
+ * @returns A React element that renders the matched routes or `null` if no matches
2370
+ */
2371
+ declare function renderMatches(matches: RouteMatch[] | null): React.ReactElement | null;
2372
+ declare function useRouteComponentProps(): {
2373
+ params: Readonly<Params<string>>;
2374
+ loaderData: any;
2375
+ actionData: any;
2376
+ matches: UIMatch<unknown, unknown>[];
2377
+ };
2378
+ type RouteComponentProps = ReturnType<typeof useRouteComponentProps>;
2379
+ type RouteComponentType = React.ComponentType<RouteComponentProps>;
2380
+ declare function WithComponentProps({ children, }: {
2381
+ children: React.ReactElement;
2382
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2383
+ declare function withComponentProps(Component: RouteComponentType): () => React.ReactElement<{
2384
+ params: Readonly<Params<string>>;
2385
+ loaderData: any;
2386
+ actionData: any;
2387
+ matches: UIMatch<unknown, unknown>[];
2388
+ }, string | React.JSXElementConstructor<any>>;
2389
+ declare function useHydrateFallbackProps(): {
2390
+ params: Readonly<Params<string>>;
2391
+ loaderData: any;
2392
+ actionData: any;
2393
+ };
2394
+ type HydrateFallbackProps = ReturnType<typeof useHydrateFallbackProps>;
2395
+ type HydrateFallbackType = React.ComponentType<HydrateFallbackProps>;
2396
+ declare function WithHydrateFallbackProps({ children, }: {
2397
+ children: React.ReactElement;
2398
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2399
+ declare function withHydrateFallbackProps(HydrateFallback: HydrateFallbackType): () => React.ReactElement<{
2400
+ params: Readonly<Params<string>>;
2401
+ loaderData: any;
2402
+ actionData: any;
2403
+ }, string | React.JSXElementConstructor<any>>;
2404
+ declare function useErrorBoundaryProps(): {
2405
+ params: Readonly<Params<string>>;
2406
+ loaderData: any;
2407
+ actionData: any;
2408
+ error: unknown;
2409
+ };
2410
+ type ErrorBoundaryProps = ReturnType<typeof useErrorBoundaryProps>;
2411
+ type ErrorBoundaryType = React.ComponentType<ErrorBoundaryProps>;
2412
+ declare function WithErrorBoundaryProps({ children, }: {
2413
+ children: React.ReactElement;
2414
+ }): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
2415
+ declare function withErrorBoundaryProps(ErrorBoundary: ErrorBoundaryType): () => React.ReactElement<{
2416
+ params: Readonly<Params<string>>;
2417
+ loaderData: any;
2418
+ actionData: any;
2419
+ error: unknown;
2420
+ }, string | React.JSXElementConstructor<any>>;
2421
+
1586
2422
  interface IndexRouteObject {
1587
2423
  caseSensitive?: AgnosticIndexRouteObject["caseSensitive"];
1588
2424
  path?: AgnosticIndexRouteObject["path"];
@@ -1635,8 +2471,9 @@ interface DataRouteMatch extends RouteMatch<string, DataRouteObject> {
1635
2471
  type PatchRoutesOnNavigationFunctionArgs = AgnosticPatchRoutesOnNavigationFunctionArgs<RouteObject, RouteMatch>;
1636
2472
  type PatchRoutesOnNavigationFunction = AgnosticPatchRoutesOnNavigationFunction<RouteObject, RouteMatch>;
1637
2473
  interface DataRouterContextObject extends Omit<NavigationContextObject, "future"> {
1638
- router: Router;
2474
+ router: Router$1;
1639
2475
  staticContext?: StaticHandlerContext;
2476
+ unstable_onError?: unstable_ClientOnErrorFunction;
1640
2477
  }
1641
2478
  declare const DataRouterContext: React.Context<DataRouterContextObject | null>;
1642
2479
  declare const DataRouterStateContext: React.Context<RouterState | null>;
@@ -1700,4 +2537,4 @@ interface RouteContextObject {
1700
2537
  }
1701
2538
  declare const RouteContext: React.Context<RouteContextObject>;
1702
2539
 
1703
- export { type ErrorResponse as $, Action as A, type BlockerFunction as B, type StaticHandler as C, type DataStrategyFunction as D, type GetScrollRestorationKeyFunction as E, type FutureConfig as F, type GetScrollPositionFunction as G, type HydrationState as H, type InitialEntry as I, type StaticHandlerContext as J, type Fetcher as K, type LazyRouteFunction as L, type MiddlewareEnabled as M, type NonIndexRouteObject as N, type NavigationStates as O, type PatchRoutesOnNavigationFunction as P, type RouterSubscriber as Q, type Router as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type RouterNavigateOptions as V, type RouterFetchOptions as W, type RevalidationState as X, type DataStrategyFunctionArgs as Y, type DataStrategyMatch as Z, type DataStrategyResult as _, type RelativeRoutingType as a, type FormEncType as a0, type FormMethod as a1, type HTMLFormMethod as a2, type PathParam as a3, type RedirectFunction as a4, type unstable_RouterContext as a5, type ShouldRevalidateFunctionArgs as a6, unstable_createContext as a7, createPath as a8, parsePath as a9, type History as aA, type CreateStaticHandlerOptions as aB, IDLE_NAVIGATION as aa, IDLE_FETCHER as ab, IDLE_BLOCKER as ac, data as ad, generatePath as ae, isRouteErrorResponse as af, matchPath as ag, matchRoutes as ah, redirect as ai, redirectDocument as aj, replace as ak, resolvePath as al, type PatchRoutesOnNavigationFunctionArgs as am, type Future as an, createBrowserHistory as ao, invariant as ap, createRouter as aq, ErrorResponseImpl as ar, DataRouterContext as as, DataRouterStateContext as at, FetchersContext as au, LocationContext as av, NavigationContext as aw, RouteContext as ax, ViewTransitionContext as ay, type RouteManifest as az, type IndexRouteObject as b, type Location as c, type Navigator as d, type RouterInit as e, type RouteObject as f, type RouteMatch as g, type Params as h, type ActionFunctionArgs as i, type LoaderFunctionArgs as j, type ActionFunction as k, type LoaderFunction as l, type DataRouteMatch as m, type unstable_MiddlewareFunction as n, unstable_RouterContextProvider as o, DataWithResponseInit as p, type NavigateOptions as q, type Blocker as r, type ParamParseKey as s, type Path as t, type unstable_MiddlewareNextFunction as u, type PathPattern as v, type PathMatch as w, type Navigation as x, type RouterState as y, type DataRouteObject as z };
2540
+ export { type DataStrategyMatch as $, type ActionFunctionArgs as A, type BlockerFunction as B, type PatchRoutesOnNavigationFunction as C, type DataStrategyResult as D, type ErrorBoundaryType as E, type DataRouteObject as F, type StaticHandler as G, type HydrationState as H, type InitialEntry as I, type GetScrollPositionFunction as J, type GetScrollRestorationKeyFunction as K, type Location as L, type MiddlewareEnabled as M, type NavigateOptions as N, type StaticHandlerContext as O, type Params as P, type Fetcher as Q, type RouterProviderProps as R, type ShouldRevalidateFunction as S, type To as T, type UIMatch as U, type NavigationStates as V, type RouterSubscriber as W, type RouterNavigateOptions as X, type RouterFetchOptions as Y, type RevalidationState as Z, type DataStrategyFunctionArgs as _, type RouterInit as a, mapRouteProperties as a$, type ErrorResponse as a0, type FormEncType as a1, type FormMethod as a2, type HTMLFormMethod as a3, type LazyRouteFunction as a4, type PathParam as a5, type RedirectFunction as a6, type unstable_RouterContext as a7, type ShouldRevalidateFunctionArgs as a8, unstable_createContext as a9, type RouterProps as aA, type RoutesProps as aB, Await as aC, MemoryRouter as aD, Navigate as aE, Outlet as aF, Route as aG, Router as aH, RouterProvider as aI, Routes as aJ, createMemoryRouter as aK, createRoutesFromChildren as aL, createRoutesFromElements as aM, renderMatches as aN, type Future as aO, createBrowserHistory as aP, invariant as aQ, createRouter as aR, ErrorResponseImpl as aS, DataRouterContext as aT, DataRouterStateContext as aU, FetchersContext as aV, LocationContext as aW, NavigationContext as aX, RouteContext as aY, ViewTransitionContext as aZ, hydrationRouteProperties as a_, createPath as aa, parsePath as ab, IDLE_NAVIGATION as ac, IDLE_FETCHER as ad, IDLE_BLOCKER as ae, data as af, generatePath as ag, isRouteErrorResponse as ah, matchPath as ai, matchRoutes as aj, redirect as ak, redirectDocument as al, replace as am, resolvePath as an, type Navigator as ao, type PatchRoutesOnNavigationFunctionArgs as ap, type RouteMatch as aq, type AwaitProps as ar, type IndexRouteProps as as, type LayoutRouteProps as at, type MemoryRouterOpts as au, type MemoryRouterProps as av, type NavigateProps as aw, type OutletProps as ax, type PathRouteProps as ay, type RouteProps as az, type unstable_MiddlewareNextFunction as b, WithComponentProps as b0, withComponentProps as b1, WithHydrateFallbackProps as b2, withHydrateFallbackProps as b3, WithErrorBoundaryProps as b4, withErrorBoundaryProps as b5, type RouteManifest as b6, type History as b7, type FutureConfig as b8, type CreateStaticHandlerOptions as b9, type LoaderFunctionArgs as c, type ActionFunction as d, type LoaderFunction as e, type DataRouteMatch as f, type unstable_MiddlewareFunction as g, unstable_RouterContextProvider as h, DataWithResponseInit as i, type Router$1 as j, type DataStrategyFunction as k, type Blocker as l, type RelativeRoutingType as m, type ParamParseKey as n, type Path as o, type PathPattern as p, type PathMatch as q, type Navigation as r, Action as s, type RouteObject as t, type unstable_ClientOnErrorFunction as u, type IndexRouteObject as v, type RouteComponentType as w, type HydrateFallbackType as x, type NonIndexRouteObject as y, type RouterState as z };