https://github.com/mskelton/use-strict-params
Strictly typed params for React router.
https://github.com/mskelton/use-strict-params
params react react-router strict typescript
Last synced: 18 days ago
JSON representation
Strictly typed params for React router.
- Host: GitHub
- URL: https://github.com/mskelton/use-strict-params
- Owner: mskelton
- License: isc
- Created: 2023-12-01T00:27:17.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-24T15:16:58.000Z (over 1 year ago)
- Last Synced: 2025-12-25T14:50:07.555Z (about 2 months ago)
- Topics: params, react, react-router, strict, typescript
- Language: TypeScript
- Homepage: https://npm.im/use-strict-params
- Size: 174 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# use-strict-params
[](https://github.com/mskelton/use-strict-params/actions)
[](https://www.npmjs.com/package/use-strict-params)
Strictly typed params for React router.
## Installation
### npm
```sh
npm install use-strict-params
```
### Yarn
```sh
yarn add use-strict-params
```
### pnpm
```sh
pnpm add use-strict-params
```
### bun
```sh
bun add use-strict-params
```
## Usage
### `useStrictParams`
A typed variant of `useParams`. The following types are supported:
- `String`
- `Number`
- `Boolean`
- `Date`
```typescript
const { userId } = useStrictParams({ userId: Number })
```
### `useStrictSearchParams`
A typed variant of `useSearchParams`. The following types are supported:
- `String`
- `Number`
- `Boolean`
- `Date`
```typescript
const { query } = useStrictSearchParams({ query: String })
```
### `Optional`
Marks a type as optional which will change the return type to allow `null`.
```typescript
const { query } = useStrictSearchParams({ query: Optional(String) })
```