How to handle partial dynamic route segments in React Router v7?
08:38 01 Feb 2026

I am currently migrating my codebase from React Router v5 to v7 and have hit a roadblock regarding route validation.

In my older v5 codebase, we relied on path-to-regexp support to create routes with partial dynamic segments and regex validation, like these:

  • /:bankName-user-buy/
  • /user-buy-:bankName/

In these patterns, bankName is a dynamic value, but the URL must also contain the static string user-buy. Since React Router v7 no longer supports path-to-regexp or partial segments, these patterns are failing. When I try to use them, the router often treats them as a broad catch-all * pattern or simply fails to match the dynamic part correctly because it expects the: to be at the start of a full segment.

Is there any workaround for this to solve this issue?

reactjs react-router remix