Skip to main content


Utilities to match/validate route params for Deno Fresh.


Wrap your handler function with matchRouteParams to validate the current route’s params.

// route: /:groupId/:username/
// at routes/[groupId]/[username].tsx

import { HandlerContext } from "";
import { matchRouteParams } from "";

export const handler = matchRouteParams(
  (req: Request, ctx: HandlerContext): Response => {
    // handle request...
    groupId: /^([0-9a-zA-Z]{8})$/,
    username: (param) => {
      return ["shaquille.oatmeal", "averagestudent" /*...*/].includes(param);

// ...

matchRouteParams can wrap Handlers object as well, no need to wrap every single of its Handler functions.


You can open an issue or make a PR, I’ll try to check and merge (if possible) quickly.


Under MIT license.