Skip to content

useUrlSearchString

function useUrlSearchString(): string;

Defined in: tanstack/react/use-url-search-string.ts:24

Reactive read of the full URL query string from the adapter store. Unlike a router hook, this reflects shallow updates (History-API writes that don’t fire router/popstate events). Useful for debugging and live URL readouts.

Returns the store’s optimistic query string without a leading ? ("page=2&sort=name", or ""). It updates as soon as a setter is called, before the rate-limited URL commit.

string

import { useUrlSearchString } from "@xtandard/lib/tanstack";
function UrlDebug() {
const search = useUrlSearchString(); // e.g. "q=shoes&page=2"
return <code>?{search}</code>;
}