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

# singleIndex

> Mapping between search state and browser URL for backwards compatibility with InstantSearch v3.

```ts Signature theme={"system"}
singleIndex(
  indexName: string,
);
```

## Import

<CodeGroup>
  ```js Package manager theme={"system"}
  import { singleIndex } from "instantsearch.js/es/lib/stateMappings";
  ```

  ```js CDN theme={"system"}
  const { singleIndex } = instantsearch.stateMappings;
  // or directly use instantsearch.stateMappings.singleIndex()
  ```
</CodeGroup>

## About this widget

The `singleIndex` state mapping can be applied to the `instantsearch` object's [routing](/doc/api-reference/widgets/instantsearch/js#param-routing) option.
It enables backward compatibility with version 3.x.

The mapping applies the following transformations:

* Omits the `configure` widget
* Uses the given index for the top level

```js JavaScript icon=code theme={"system"}
singleIndex("instant_search").stateToRoute({
  instant_search: {
    query: "Apple",
    page: 5,
    configure: {
      hitsPerPage: 4,
    },
  },
});

// {
//   query: 'Apple',
//   page: 5,
// }
```

## Examples

```js JavaScript icon=code theme={"system"}
instantsearch({
  // ...
  routing: {
    stateMapping: singleIndex("instant_search"),
  },
});
```

## Options

<ParamField body="indexName" type="string" required>
  The name of the index to get the state from,
  usually the same value provided to [`instantsearch`](/doc/api-reference/widgets/instantsearch/js).

  ```js JavaScript icon=code theme={"system"}
  singleIndex("instant_search");
  ```
</ParamField>
