Q12: What are Catch-all routes [...slug].js in the Pages Router?
Catch-all routes using [...slug].js match multiple nested URL path segments. For example, pages/post/[...slug].js matches /post/a, /post/a/b, and /post/a/b/c. Query parameters return slug as an array of path segments (['a', 'b', 'c']).
Key Takeaways
Syntax:
[...slug].jsmatches multiple URL path segments.Extracted as an array of string segments.
Knowledge Check
For the file pages/docs/[...slug].js, what value does router.query.slug hold when visiting /docs/api/v1/users?