URLParamsParser

Parsing path parameters into typed values.

URLParamsParser is the default ParsersRegistry.urlParamsParser. It fills Context.params from the raw values Bun's router matched, decoding and coercing each one.

Contents
  1. URLParamsParser

URLParamsParser

class

class URLParamsParser extends ParserBase<Record<string, string>>

Turns matched path parameters into a typed object.

The flattest of the parsers: path parameters are named by the route pattern, so there is no nesting to recover — no bracket notation, no repeated keys. Each value is percent-decoded and then coerced through ParserBase.tryParseJSON, so /users/42 yields a number rather than a string.

URLParamsParser.parse()

parse(input: Record<string, string>): Record<string, unknown>

Parses matched path parameters.

Parameters

Returns — The decoded, coerced parameters, on a null prototype from createSafeObject.