Skip to content

Commit

Permalink
doc: Add loaders to README
Browse files Browse the repository at this point in the history
  • Loading branch information
franky47 committed Jan 14, 2025
1 parent 83de9ba commit 89cd940
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,25 @@ const search = await setCoordinates({
})
```

## Loaders

To parse search params as a one-off operation, you can use a **loader function**:

```tsx
import { createLoader } from 'nuqs' // or 'nuqs/server'
const searchParams = {
q: parseAsString,
page: parseAsInteger.withDefault(1)
}

const loadSearchParams = createLoader(searchParams)

const { q, page } = loadSearchParams('?q=hello&page=2')
```

It accepts various types of inputs (strings, URL, URLSearchParams, Request, Promises, etc.). [Read more](https://nuqs.47ng.com/docs/server-side#loaders)

## Accessing searchParams in Server Components

If you wish to access the searchParams in a deeply nested Server Component
Expand Down

0 comments on commit 89cd940

Please sign in to comment.