> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# InstantSearchSSRProvider

> Forwards the server-side search state to the InstantSearch root component.

<Note>
  This is the **React InstantSearch v7** documentation.
  If you're upgrading from v6, see the [upgrade guide](/doc/guides/building-search-ui/upgrade-guides/react/#migrate-from-react-instantsearch-v6-to-react-instantsearch-v7).
  If you were using React InstantSearch Hooks,
  this v7 documentation applies—just check for [necessary changes](/doc/guides/building-search-ui/upgrade-guides/react/#migrate-from-react-instantsearch-hooks-to-react-instantsearch-v7).
  To continue using v6, you can find the [archived documentation](https://algolia.com/old-docs/deprecated/instantsearch/react/v6/api-reference/instantsearch/).
</Note>

```tsx Signature theme={"system"}
<InstantSearchSSRProvider initialResults={object}>
  {children}
</InstantSearchSSRProvider>
```

## Import

```js JavaScript icon=code theme={"system"}
import { InstantSearchSSRProvider } from "react-instantsearch";
```

## About this component

<Note>
  If you use Next.js's App Router, a dedicated
  `react-instantsearch-nextjs` package is available.
  To learn more, see [App router](/doc/guides/building-search-ui/going-further/server-side-rendering/react#with-next-js-app-router).
</Note>

`<InstantSearchSSRProvider>` is the provider component that forwards the server state to
[`<InstantSearch>`](/doc/api-reference/widgets/instantsearch/react).
It's designed to support server-side rendering (SSR) in your InstantSearch application.

To retrieve the server state and pass it down to the component,
you need to use [`getServerState`](/doc/api-reference/widgets/server-state/react).

To learn more, see [Server-side rendering](/doc/guides/building-search-ui/going-further/server-side-rendering/react)

## Examples

<CodeGroup>
  ```jsx JavaScript theme={"system"}
  import React from "react";
  import { liteClient as algoliasearch } from "algoliasearch/lite";
  import { InstantSearch, InstantSearchSSRProvider } from "react-instantsearch";

  const searchClient = algoliasearch("YourApplicationID", "YourSearchOnlyAPIKey");

  function App({ serverState }) {
    return (
      <InstantSearchSSRProvider {...serverState}>
        <InstantSearch indexName="indexName" searchClient={searchClient}>
          {/* Widgets */}
        </InstantSearch>
      </InstantSearchSSRProvider>
    );
  }
  ```

  ```tsx TypeScript theme={"system"}
  import React from "react";
  import { liteClient as algoliasearch } from "algoliasearch/lite";
  import {
    InstantSearch,
    InstantSearchServerState,
    InstantSearchSSRProvider,
  } from "react-instantsearch";

  const searchClient = algoliasearch("YourApplicationID", "YourSearchOnlyAPIKey");

  type AppProps = {
    serverState?: InstantSearchServerState;
  };

  function App({ serverState }: AppProps) {
    return (
      <InstantSearchSSRProvider {...serverState}>
        <InstantSearch indexName="indexName" searchClient={searchClient}>
          {/* Widgets */}
        </InstantSearch>
      </InstantSearchSSRProvider>
    );
  }
  ```
</CodeGroup>

Check the [SSR example](https://github.com/algolia/react-instantsearch/blob/master/examples/server-side-rendering/src/App.js) for full markup.

## Props

<ParamField body="initialResults" type="InitialResults">
  The initial results to forward to [`<InstantSearch>`](/doc/api-reference/widgets/instantsearch/react).

  You should spread the whole server state object returned by [`getServerState`](/doc/api-reference/widgets/server-state/react), which contains `initialResults`.

  <CodeGroup>
    ```jsx JavaScript theme={"system"}
    <InstantSearchSSRProvider {...serverState}>
      <InstantSearch indexName="indexName" searchClient={searchClient}>
        {/* Widgets */}
      </InstantSearch>
    </InstantSearchSSRProvider>;
    ```

    ```ts TypeScript theme={"system"}
    type InitialResult = {
      state: SearchParameters;
      results: SearchResults;
    };

    type InitialResults = Record<string, InitialResult>;
    ```
  </CodeGroup>
</ParamField>

<ParamField body="children" type="React.ReactNode">
  The part of the app that renders [`<InstantSearch>`](/doc/api-reference/widgets/instantsearch/react).
</ParamField>
