% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hooks.R
\name{useSearchParams}
\alias{useSearchParams}
\title{useSearchParams}
\usage{
useSearchParams(into = NULL, as = "children", param = NULL, render = NULL, ...)
}
\arguments{
\item{into}{A component (HTML tag or \pkg{shiny.react}-based element)
that will receive the hook data as the specified prop.}

\item{as}{Character. The name of the component's prop to inject the hook
data into (by default \code{"children"} for text display, \code{"rows"} for
a data grid, \code{"value"} for an input).}

\item{param}{Character. Name of a single query parameter to extract.
  Returns a character vector of all values for that key (length 0 if
  absent, length 1+ otherwise). When \code{NULL}, returns a named list
  mapping each key to its vector of values.

  \strong{Empty vs. missing.} A missing key produces a length-0 vector,
  which renders as an empty string when injected with the default
  \code{as = "children"}. If you need to distinguish "absent" from
  "present-but-empty" (e.g. show a placeholder), use the \code{render}
  form and branch on \code{Array.isArray(v) && v.length === 0}, e.g.
  \code{render = JS("v => v.length ? v.join(', ') : <em>none</em>")}.}

\item{render}{Optional \code{\link{JS}} function \code{(value) => ReactNode}
used in place of \code{into}/\code{as}. Mirrors the native React Router
pattern for cases where a single prop is not expressive enough (e.g.
\code{JS("v => `${v.first} ${v.last}`")}).}

\item{...}{Additional props to pass to the component.}
}
\description{
\url{https://api.reactrouter.com/v7/functions/react-router.useSearchParams.html}
}
\details{
Calls the \code{useSearchParams()} hook and injects the result
\code{as} a prop of the \code{into} component. Use the \code{param}
argument to extract a query parameter by name.

Values are always returned as character vectors so that repeated keys
(e.g. \code{"?tag=a&tag=b"}) are preserved. When injected as
\code{"children"}, vectors are joined with \code{", "}; for custom
formatting, use \code{render}.

\strong{Reading vs. writing.} The upstream JS hook returns a tuple
\code{[searchParams, setSearchParams]}. This wrapper splits the two paths:
\itemize{
  \item \code{into} / \code{as} — \emph{read-only}. Receives the parsed
    params (or one \code{param}) and ignores the setter.
  \item \code{render} — receives both as \code{(params, setSearchParams)},
    so use this form when you need to update the URL programmatically:
    \preformatted{
  useSearchParams(render = JS(
    "(p, set) => <button onClick={() => set({tag:'b'})}>Filter</button>"
  ))
    }
}
}
