Diagnostics

LUM5002: Invalid route file

A file under src/routes is not a valid route file.

Severity: error · Category: routing and server (5xxx)

Reported by: the route scanner (lumiose check, typegen, dev server).

#What it means

Route files use the Next.js App Router names: page.stsx/page.tsx, route.ts, and the layout, not-found and error component files. Any other file in src/routes is a colocated module that the router ignores, and so is everything below a private _folder. The message says which rule a route file broke, for example:

  • a special file with the wrong extension: page.ts, layout.ts, or route.tsx (an endpoint is route.ts);
  • a Next.js special file Lumiose does not have: loading, template, default or global-error, a route file below an @slot folder (parallel routes) or a (.), (..) or (...) folder (intercepting routes);
  • an invalid segment folder ([], [a-b], post-[id], a broken (group, unsafe characters), a rest segment that is not the last one, or a param used twice;
  • export const mode that is not a string literal of static, server or spa, or ssr that is not true/false, or let instead of const;
  • export const locales that is not a list of locale literals, "all" or a function, or that lists a locale lumiose({ i18n }) does not configure (Internationalization);
  • a warning for an export that has no effect: ssr = false outside spa routes, prerender in an endpoint or in a layout or page whose mode is static or server (a spa layout's prerender applies to the pages below it), or locales without lumiose({ i18n }).

#Example

text
src/routes/blog/loading.stsx        Lumiose has no loading files
src/routes/@modal/page.stsx         Lumiose has no parallel routes
src/routes/api/route.tsx            an endpoint is a route.ts file

#How to fix it

Follow the help text. Show pending UI with <Suspense fallback={…}> instead of loading, use a layout instead of template, rename the folder or file, and declare export const mode = "server"; with a literal. To keep a file next to the routes without the router reading it, give it another name or move it into a _folder.