use-strict-params
v1.0.1
Published
Strictly typed params for React router.
Downloads
49
Maintainers
Readme
use-strict-params
Strictly typed params for React router.
Installation
npm
npm install use-strict-params
Yarn
yarn add use-strict-params
pnpm
pnpm add use-strict-params
bun
bun add use-strict-params
Usage
useStrictParams
A typed variant of useParams
. The following types are supported:
String
Number
Boolean
Date
const { userId } = useStrictParams({ userId: Number })
useStrictSearchParams
A typed variant of useSearchParams
. The following types are supported:
String
Number
Boolean
Date
const { query } = useStrictSearchParams({ query: String })
Optional
Marks a type as optional which will change the return type to allow null
.
const { query } = useStrictSearchParams({ query: Optional(String) })