Use Params

GitHub

Invisible client components that report the current search params, pathname, or a numeric route param whenever they change.

Installation

bash
pnpm dlx shadcn@latest add @cs/use-params

Usage

tsx
import { UseSearchParams } from "@/components/cs/use-params"
tsx
<UseSearchParams onChange={(value) => console.log(value)} />

API Reference

UseSearchParams

Invisible client component that reports the current search params string whenever it changes.

Props

NameTypeDefaultDescription
onChange *(value: string) => void--

UseSelectedIdParam

Invisible client component that reports a numeric route param's value whenever it changes.

Props

NameTypeDefaultDescription
onChange *(value: number) => void--
paramId *string | null--

UsePathname

Invisible client component that reports the current pathname whenever it changes.

Props

NameTypeDefaultDescription
onChange *(value: string) => void--

Dependencies