Skip to content
Source
Sign inSign up
TanStack/router

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

Opentimofei-iatsenko(GitHub profile, opens in a new tab) opened this issue 2 comments

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

  1. your reproducer does not show this warning. also, nesting route under index is not supported and might cause this

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

  3. your reproducer does not show this warning.

    Open a browser console in the stackblitz. Warning is logged during runtime of app, not the build time.

    Image

    also, nesting route under index is not supported and might cause this

    In a stackblitz, index is not nested

    Image

    But it still cause the issue

    Thanks for looking into the issue!

Sign in to join this conversation.