Skip to main content

Function: useSearch()

useSearch<T, P>(params, options): useSearchResponse<T>

Defined in: packages/next/src/data/hooks/useSearch.ts:18

The useSearch hook. Returns a collection of search entities

In order to automatically map URL params create a catch-all route named [...path].js. You can create the catch-all at any level e.g: pages/search/[[...path]].js

The pages/search/[[...path]].js route for instance would yield a URL like this: /search/[term]/page/[number], /search/[term] etc

Type Parameters​

T​

T extends PostEntity = PostEntity

P​

P extends PostsArchiveParams = PostsArchiveParams

Parameters​

params​

Partial<P> = {}

The parameters accepted by the hook

options​

FetchHookOptions<FetchResponse<T[]>> = {}

Options for the SWR configuration

Returns​

useSearchResponse<T>