Skip to content
Source
Sign inSign up
TanStack/router

Inconsistent `router.matchRoute` documentation – mentions RouteMatch, but actually returns params #3875

Send to my agent
ClosedRedbird10(GitHub profile, opens in a new tab) opened this issue 2 comments

Which project does this relate to?

Router

Describe the bug

The documentation for router.matchRoute is inconsistent and confusing about what the method actually returns.

  • At the top of the doc, it says the method returns a matched route’s params or false.
  • At the bottom of the doc, it says it returns a RouteMatch object or false.
  • In actual usage, router.matchRoute() returns only the params, not a RouteMatch object.

This mismatch can cause confusion, especially since:

  • useMatchRoute() also returns params | false (correctly documented)
  • router.matchRoutes() returns an array of full RouteMatch objects

It’s unclear whether the return type or the implementation is intended behavior — but either way, the docs should be aligned with the actual return.

In my case, I wanted to use router.matchRoute() in a child loader to access a grandparent route's loaderData, but since it only returns params, it's not possible. I'd expect router.matchRoute() to return a full RouteMatch object to allow more control and consistency across the API.

Your Example Website or App

/

Steps to Reproduce the Bug or Issue

Not applicable — this is a documentation inconsistency, not a runtime bug.

Expected behavior

I would expect router.matchRoute() to return a full RouteMatch object (or false), as suggested in the lower part of the documentation.

This would provide consistency with .matchRoutes(), and allow use cases like accessing loaderData from grandparent routes — without having to manually walk through .matchRoutes() results.

Screenshots or Videos

Image

Platform

N/A

Additional context

No response

  1. yeah the docs are outdated here. matchRoute does indeed not return a RouteMatch. feel free to create a PR to the docs

  2. schiller-manuel(GitHub profile, opens in a new tab) added labelsdocumentation

  3. Thanks for the clarification. I've opened a PR to update the docs here: #3896

  4. SeanCassiere closed this

  5. SeanCassiere closed this

Sign in to join this conversation.