From ff5e641639cf58ad387eb2b68098c8179985a978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Tue, 14 Jan 2025 11:17:52 +0100 Subject: [PATCH] chore: Try to avoid bursting e2e-next CI caching (#859) --- .github/workflows/ci-cd.yml | 2 +- README.md | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 97860972..a9dfd5f5 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -97,7 +97,7 @@ jobs: run: pnpm install --frozen-lockfile ${{ matrix.next-version != 'latest' && '--filter e2e-next...' || '' }} - name: Install Next.js version ${{ matrix.next-version }} if: ${{ matrix.next-version != 'local' }} - run: pnpm add --filter e2e-next --filter nuqs next@${{ matrix.next-version }} + run: pnpm add --filter e2e-next next@${{ matrix.next-version }} - name: Run integration tests run: pnpm run test ${{ github.event_name == 'workflow_dispatch' && '--force' || '' }} --filter e2e-next env: diff --git a/README.md b/README.md index 356d7b35..6e2ca286 100644 --- a/README.md +++ b/README.md @@ -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