route-params-must-be-defined - ESLint plugin rules

This rule requires properties accessed on req.params in an API route handler to correspond to a [param] folder in the route path.

Severity#

error. This rule is enabled in the recommended preset.

What it Targets#

This rule targets route.ts and route.js files in your project's src/api directory. It reports access to a req.params property that has no matching [param] folder in the route path.

The following code is reported by the rule, since the route has no foo parameter:

src/api/admin/products/[id]/route.ts
1export const GET = (req, res) => {2  const x = req.params.foo3}

Instead, access a parameter defined by a [param] folder:

src/api/admin/products/[id]/route.ts
1export const GET = (req, res) => {2  const x = req.params.id3}

Why it's Important#

A route parameter is only available on req.params when a [param] folder defines it in the route path. Accessing an undefined parameter returns undefined, which often points to a typo or a missing folder.

Learn more in the Route Parameters documentation.

Fixable#

This rule isn't auto-fixable.

Was this page helpful?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵