Skip to content

Commit

Permalink
doc: Add docs for UrlKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 committed Jan 13, 2025
1 parent 8b6d3e9 commit 4036594
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/docs/content/docs/batching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,24 @@ setCoordinates({
})
```

As your application grows, you may want to reuse these parsers and urlKeys
definitions across multiple components or nuqs features
(like [loaders](./server-side#loaders) or a [serializer](./utilities#serializer-helper)).

You can use the `UrlKeys{:ts}` type helper for this:

```ts
// [!code word:UrlKeys]
import { type UrlKeys } from 'nuqs' // or 'nuqs/server'
export const coordinatesParsers = {
latitude: parseAsFloat.withDefault(45.18),
longitude: parseAsFloat.withDefault(5.72)
}

export const coordinatesUrlKeys: UrlKeys<typeof coordinatesParsers> = {
latitude: 'lat',
longitude: 'lng'
}
```

0 comments on commit 4036594

Please sign in to comment.