TanStack / TanStack/router

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

Open
#7,691 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

information needed
Dominant language
TypeScript
Stars
15.1k
Forks
1.9k
Avg merge
1d 20h
Merged PRs (30d)
143

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/routes/index.tsx and the generated layout/index route structure, then trace the development warning reached by or router.navigate(). Done when navigating to /rsg/activity-reminder produces no false-positive warning while still selecting the layout/index route correctly; use the linked StackBlitz reproduction to verify.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.