Skip to content

Nested Routes Not Recognized in Remix 2.16.4 with Vite #10569

@mkd0r

Description

@mkd0r

Reproduction

Hello Remix team,

I’m using Remix 2.16.4 and noticed that nested routes are not being automatically recognized. My app/routes structure is as follows:

app/
├── root.tsx
├── routes/
│ ├── _index.tsx
│ ├── create.tsx
│ ├── message.tsx
│ ├── register.tsx
│ ├── settings/
│ │ ├── index.tsx // /settings works
│ │ └── profile/
│ │ └── index.tsx // /settings/profile returns 404

Running npx remix routes does not show /settings/profile:

Visiting http://localhost:5173/settings/profile in the browser results in a 404

Error: No route matches URL "/settings/profile" at getInternalRouterError (.../node_modules/@remix-run/router/router.ts:5550:5)

What I Tried:

Deleted node_modules, .cache, and build, then ran yarn install and yarn dev—issue persists.
Flat route (settings.profile.tsx) works, but nested (settings/profile/index.tsx) is not recognized.
Similar issue reported in #10460, but mine involves nested routes.

Environment:

Remix: @remix-run/dev@2.16.4
Node: [add your Node version, e.g., 20.11.0]
OS: macOS [add your version, e.g., 14.3]
Package Manager: Yarn

Manually defining routes in remix.config.js works:

routes: async defineRoutes => { return defineRoutes(route => { route("/settings/profile", "routes/settings/profile/index.tsx"); }); }

Request:

Could you check why nested routes aren’t being detected and if this is a Vite scanning issue? Thanks!

System Info

System Version: macOS 14.6.1 (23G93)
Kernel Version: Darwin 23.6.0

Node version: v20.16.0

Used Package Manager

npm

Expected Behavior

Expected Behavior:

Based on Remix’s file-based routing system, I expect app/routes/settings/profile/index.tsx to be automatically recognized as the /settings/profile route and appear in the npx remix routes output. When visiting http://localhost:5173/settings/profile in the browser, it should render the content of index.tsx (e.g.,

PROFILTE PAGE

) instead of returning a 404 error.

Actual Behavior

Remix does not recognize app/routes/settings/profile/index.tsx as a route. It is missing from the npx remix routes output, and visiting http://localhost:5173/settings/profile in the browser results in a 404 error with the message: Error: No route matches URL "/settings/profile". However, flat routes like settings.profile.tsx work as expected.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions