Use Params
GitHubInvisible 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-paramsUsage
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
| Name | Type | Default | Description |
|---|---|---|---|
| onChange * | (value: string) => void | - | - |
UseSelectedIdParam
Invisible client component that reports a numeric route param's value whenever it changes.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| onChange * | (value: number) => void | - | - |
| paramId * | string | null | - | - |
UsePathname
Invisible client component that reports the current pathname whenever it changes.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| onChange * | (value: string) => void | - | - |