The ID that will be used for the Shiny input (input$<id>).
The initial value for the input, used only on first
mount (same semantics as React.useState's initial value). Subsequent
renders may pass a different value, but it will be ignored. This means
inline object/array literals like {} or [] are safe to pass — they
won't cause unnecessary re-renders.
Optional configuration object.
OptionaldebounceMs?: numberDebounce delay in milliseconds for input updates (default: 100).
Optionalnamespace?: string | nullOptionalpriority?: EventPriorityPriority level for the input event (from Shiny's EventPriority enum).
Optionaltype?: stringOptional input-handler name appended as ${id}:${type}
when sending to Shiny. Use to route values through a Shiny input handler
such as "shiny.datetime". Must be non-empty and contain no whitespace or
:. The first mount of a given id finalizes the policy (an explicit type
or the absence of one); a later mount that omits type is a no-op, but a
later mount that supplies a type disagreeing with the finalized policy
throws — the handler name is a server-side semantic and must be consistent
across every useShinyInput / useSetShinyInput call for the same id.
A tuple containing the current value and a function to set the
value: [value, setValue].
A React hook for managing a Shiny input value.
This hook initializes a state variable with
defaultValueand returns the current value and a function to update it, similar toReact.useState.When the component mounts, it waits for Shiny to initialize. Once Shiny is initialized, this hook registers the input with the Shiny React registry and uses debounced updates to send values to the Shiny server via
window.Shiny.setInputValue().The hook supports debouncing to optimize performance by batching rapid updates, and allows setting priority levels for input events.
Note: This hook only sends data to Shiny. It does not automatically update the React state if the input is changed on the server-side (e.g., using
updateTextInput()). For two-way binding, a custom Shiny input binding would be required.