Nitro · NITRO0019 · NITRO0020
Default-export a handler from every Nitro route file
Requires every file in a statically resolved Nitro api/ or routes/ directory to default-export an event handler and keep helpers out of the route tree. Default exports that can never serve an event, such as plain objects, constants, classes, or functions that take data instead of an event, count as missing handlers. List exports a build step reads on purpose, such as route metadata, in the allowedExports option. The rule stays disabled for ambiguous configs or configured scanDirs, apiDir, or routesDir until resolved Runtime Evidence is available.
nitro/routes/require-default-handlersrc/rule-packs/nitro/rules/require-default-handler.ts Upstream docs Run this rule
pnpm vite-doctor . --framework nitro --rules nitro/routes/require-default-handler
Why it matters
Nitro registers every file under server/api and server/routes as a route. A helper module placed there becomes a public URL with no working handler, and other routes that import it pull in a route module.
Recommended fix
Default-export a handler from each route file. Move shared helpers to server/utils/, where Nitro 2 and Nuxt auto-import them, and keep only type exports next to the handler.
Useful links
Example
Move route helpers to server/utils
Before
// server/api/_db.ts
export function getDb() {
return drizzle(useRuntimeConfig().databaseUrl)
}
After
// server/utils/db.ts
export function getDb() {
return drizzle(useRuntimeConfig().databaseUrl)
}
// server/api/users.get.ts
export default defineEventHandler(() => getDb().select().from(users))