Catch All Routes

Catch all routes are a special case of dynamic routes where the remainder of the path is matched by the wild card syntax $$.


Consider the following api app/api/docs/$$.mjs:

export async function get(req) {
  const { proxy } = req.pathParameters
  const pathSegments = proxy.split('/')
  return {
    json: { pathSegments },

Routes like /docs/quickstart or /docs/learn/routing will be matched by app/api/docs/$$.mjs.


Hard coded routes and dynamic routes take precedence over catch all routes. For example:

/docs/quickstart → app/pages/docs/quickstart.mjs
/docs/:filename → /docs/routing → app/pages/docs/$filename.mjs
/docs/:path → /docs/learning/concepts/custom → app/pages/docs/$$.mjs

Community Resources

Visit Enhance on GitHub.
Join our Discord server to chat about development and get help from the community.