> For the complete documentation index, see [llms.txt](https://search.docs.reactify.com.au/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://search.docs.reactify.com.au/components/search.md).

# Search

### Purpose

The Search component is a wrapper for the [useSearch hook](/hooks/usesearch.md), it provides a simple way to access and update the search terms while also handling special logic such as redirects.

### Usage

{% tabs %}
{% tab title="Basic" %}

```tsx
import React from "react";
import { Search } from "@usereactify/search";

import { ExampleSearch } from "./ExampleSearch";

export const Component: React.FC = () => {
  return (
    <Search
      render={ExampleSearch}
    />
  );
};
```

{% endtab %}

{% tab title="ExampleSearch" %}

```tsx
import React from "react";
import { SearchProps } from "@usereactify/search";

export type ExampleSearchProps = React.ComponentProps<
  NonNullable<SearchProps["render"]>
>;

export const ExampleSearch: React.FC<ExampleSearchProps> = (props) => {
  const handleFormSubmit = React.useCallback(
    (event: React.FormEvent<HTMLFormElement>) => {
      event.preventDefault();
      props.submitSearchTerm();
    },
    [props.submitSearchTerm]
  );

  const handleInputChange = React.useCallback(
    (event: React.ChangeEvent<HTMLInputElement>) => {
      props.setSearchTerm(event.target.value);
    },
    [props.setSearchTerm]
  );

  return (
    <form onSubmit={handleFormSubmit}>
      <input
        type="search"
        placeholder="Search products..."
        value={props.searchTerm}
        onChange={handleInputChange}
      />
    </form>
  );
};
```

{% endtab %}
{% endtabs %}

### Props

```typescript
type SearchProps = {
  /** Render method */
  render?: React.FC<ReturnType<typeof useSearch>>;
};
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://search.docs.reactify.com.au/components/search.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
