Skip to content

False positive warning when navigating to a route that has both a layout and an index route #7691

Description

@timofei-iatsenko

Which project does this relate to?

Router

Describe the bug

When a route has both a layout route and an index route, navigating to it (via <Link> or router.navigate()) emits a false positive dev-mode warning:

Generated path "/rsg/activity-reminder" for route "/_app/rsg/activity-reminder" matched route "/_app/rsg/activity-reminder/" instead.
This can happen when multiple route templates resolve to the same URL.
Use the route template that matches the intended route, or adjust params.stringify if it changed the target path.

Navigation works correctly — only the dev-mode validation is wrong.

Complete minimal reproducer

https://stackblitz.com/edit/github-iylugpqz?file=src%2Froutes%2Findex.tsx

Steps to Reproduce the Bug

  1. Create a layout route and an index route for the same path:
routes/
  _app/
    rsg.activity-reminder/
      route.tsx      # layout route
      index/
        route.tsx    # index route
  1. Navigate to it:
<Link to="/rsg/activity-reminder">...</Link>
  1. Observe the console warning in development.

Expected behavior

No warning. A layout route with an index route is a standard pattern.

Screenshots or Videos

No response

Platform

  • @tanstack/react-router: 1.170.16
  • @tanstack/router-core: 1.171.13

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions