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
tsRecord<string, string>
Diagram
mermaidgraph LR Route[Route pattern] --> Match[Route match] Match --> Params[Params] Params --> Handler[Route handler]
Usage
tsimport 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
Paramsas 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
Paramsthrough 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?