Nitro · NITRO0007

Use getValidatedRouterParams for validated route params

When a Nitro handler validates the whole route params object, read and validate it through the H3 utility.
NITRO0007vite-doctor/nitrorequestwarnSuggestion

Run this rule

pnpm vite-doctor . --framework nitro --rules nitro/request/prefer-validated-router-params

Why it matters

Raw request input and validation can drift apart when they are separate operations. Nitro and h3 provide validated helpers that keep parsing and validation coupled at the request boundary.

Use getValidatedRouterParams(event, validator) instead of getRouterParams(event) followed by separate validation.

Example

Keep reading and validation together

Before

export default defineEventHandler(async (event) => {
  const input = await getRouterParams(event)
  const value = validator.parse(input)

  return value
})

After

export default defineEventHandler(async (event) => {
  const value = await getValidatedRouterParams(event, validator)

  return value
})
Copyright © 2026