Skip to content

Dynamic route segment ID is undefined when used together with non-nested routes #5751

@JacobRKnudsen

Description

@JacobRKnudsen

Which project does this relate to?

Router

Describe the bug

When defining non-nested routes that include dynamic route segments, the route parameter (e.g. "$postId") appears as undefined in Tanstack Router Devtools where the dynamic string should be resolved.

Image

This causes incorrect router data to be returned, as a cache hit occurs after the route has been visited once, using the wrong ID because the dynamic segment is undefined.

This is my folder structure:

routes/
├── $postId.tsx
└── $postId_/
    └── edit.tsx

I have also provided a reproducable example.

Your Example Website or App

https://stackblitz.com/edit/github-rpqhbuv7

Steps to Reproduce the Bug or Issue

  1. Click on "Post 1"
  2. Click on "Edit post"
  3. Click on "Home"
  4. Click on "Post 2"
  5. Click on "Edit post"
  6. Data from Post 1 is shown

Expected behavior

I expect the route loader to return the data for Post 2.

Screenshots or Videos

Image

Platform

  • Router / Start Version: 1.134.12
  • OS: Windows
  • Browser: Chrome
  • Browser Version: 141.0
  • Bundler: Vite
  • Bundler Version: 7.1.7

Additional context

No response

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions