Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/react-router/src/Matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ export type UseMatchRouteOptions<
MaskOptions<TRouter, TMaskFrom, TMaskTo> &
MatchRouteOptions

/**
* Create a matcher function for testing locations against route definitions.
*
* The returned function accepts standard navigation options (`to`, `params`,
* `search`, etc.) and returns either `false` (no match) or the matched params
* object when the route matches the current or pending location.
*
* Useful for conditional rendering and active UI states.
*
* @returns A `matchRoute(options)` function that returns `false` or params.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchRouteHook
*/
export function useMatchRoute<TRouter extends AnyRouter = RegisteredRouter>() {
const router = useRouter()

Expand Down Expand Up @@ -231,6 +243,15 @@ export function useMatches<
} as any) as UseMatchesResult<TRouter, TSelected>
}

/**
* Read the full array of active route matches or select a derived subset.
*
* Useful for debugging, breadcrumbs, or aggregating metadata across matches.
*
* @returns The array of matches (or the selected value).
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useMatchesHook
*/

/**
* Read the full array of active route matches or select a derived subset.
*
Expand Down
14 changes: 14 additions & 0 deletions packages/react-router/src/useNavigate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@ import type {
UseNavigateResult,
} from '@tanstack/router-core'

/**
* Imperative navigation hook.
*
* Returns a stable `navigate(options)` function to change the current location
* programmatically. Prefer the `Link` component for user-initiated navigation,
* and use this hook from effects, callbacks, or handlers where imperative
* navigation is required.
*
* Options:
* - `from`: Optional route base used to resolve relative `to` paths.
*
* @returns A function that accepts `NavigateOptions`.
* @link https://tanstack.com/router/latest/docs/framework/react/api/router/useNavigateHook
*/
export function useNavigate<
TRouter extends AnyRouter = RegisteredRouter,
TDefaultFrom extends string = string,
Expand Down
Loading