1 ---
2 sidebar_label: "route-dynamic-folder-syntax"
3 ---
4
5 export const metadata = {
6 title: `route-dynamic-folder-syntax - ESLint plugin rules`,
7 }
8
9 # {metadata.title}
10
11 This rule requires dynamic route parameters to use `[param]` folder syntax and disallows them as the first segment of a route.
12
13 ## Severity
14
15 `error`. This rule is enabled in the [recommended](../../page.mdx#recommended) preset.
16
17 ## What it Targets
18
19 This rule targets route folders in your project's `src/api` directory and dynamic folders in your project's `src/admin/routes` directory. It reports folders that use invalid bracket syntax, such as `[[id]]` or `[...slug]`, and routes that start with a dynamic segment.
20
21 The following code is reported by the rule, since `[[id]]` isn't valid syntax:
22
23 ```ts title="src/api/admin/products/[[id]]/route.ts"
24 export const GET = (req, res) => {}
25 ```
26
27 Instead, use single-bracket syntax with an identifier name:
28
29 ```ts title="src/api/admin/products/[id]/route.ts"
30 export const GET = (req, res) => {}
31 ```
32
33 ## Why it's Important
34
35 Medusa only recognizes the `[param]` folder syntax for dynamic parameters, and a route can't start with a dynamic segment. Other patterns aren't matched, so the route isn't registered as you expect.
36
37 Learn more in the [Route Parameters documentation](!docs!/learn/fundamentals/api-routes/parameters).
38
39 ## Fixable
40
41 This rule isn't auto-fixable.