Skip to content

Params

reference
1 min readUpdated

Kind: Type

Source: src/router.ts

Type representing a map of parameters.

Params represents a map of parameter names to their values in the router. It is used to pass route-specific data between route matching, navigation, and handler code.

Definition

ts
Record<string, string>

Diagram

mermaid
graph LR
  Route[Route pattern] --> Match[Route match]
  Match --> Params[Params]
  Params --> Handler[Route handler]

Usage

ts
import type { Params } from "./router";

const params: Params = {
  userId: "user-value",
  postSlug: "post-value",
};

function handleRoute(routeParams: Params) {
  const userId = routeParams.userId;
  const postSlug = routeParams.postSlug;

  return { userId, postSlug };
}

handleRoute(params);

AI Coding Instructions

  • Treat Params as route-derived data and keep parameter names aligned with the corresponding route pattern.
  • Check for missing parameter values before relying on them in route handlers.
  • Pass Params through router and handler boundaries instead of creating unrelated parameter object types.
  • Keep parameter values in the format expected by the router before converting them for application logic.

Was this page helpful?

Download as PDF
Params — Hono (narrator proof)