React Router API Reference
    Preparing search index...

    Function href

    • Returns a resolved URL path for the specified route.

      Param values are percent-encoded for use in a path segment: characters that would change the URL structure (/, ?, #, %, whitespace, non-ASCII) are escaped, while characters that RFC 3986 allows literally in a path segment ($ & + , ; = : @) are kept as-is. Note this differs from query-string encoding (encodeURIComponent/URLSearchParams), where those characters are delimiters and must be escaped. Splat (*) values are encoded per segment, preserving / separators.

      See RFC 3986 ยง3.3

      Type Parameters

      • Path extends string

      Parameters

      • path: Path

        The route path to resolve

      • ...args: [] | [AnyParams]

        The route params to use when resolving the path

      Returns string

      The resolved URL path

      const h = href("/:lang?/about", { lang: "en" })
      // -> `/en/about`

      <Link to={href("/products/:id", { id: "abc123" })} />

      @public

      framework