How does it work?

SearchBase is a provider component that provides the SearchBase context to the child components. It binds the backend app (data source) with the UI view components (elements wrapped within SearchBase), allowing a UI component to be reactively updated every time there is a change in the data source or in other UI components.


To configure the Appbase environments

  • index string [Required] Refers to an index of the Elasticsearch cluster.

    Note: Multiple indexes can be connected to by specifying comma-separated index names.

  • url string [Required] URL for the Elasticsearch cluster

  • credentials string [Required] Basic Auth credentials if required for authentication purposes. It should be a string of the format username:password. If you are using an cluster, you will find credentials under the Security > API credentials section of the dashboard. If you are not using an cluster, credentials may not be necessary - although having open access to your Elasticsearch cluster is not recommended.

  • appbaseConfig Object allows you to customize the analytics experience when is used as a backend. It accepts an object which has the following properties:

    • recordAnalytics boolean allows recording search analytics (and click analytics) when set to true and is used as a backend. Defaults to false.
    • enableQueryRules boolean If false, then will not apply the query rules on the search requests. Defaults to true.
    • userId string It allows you to define the user id to be used to record the analytics. Defaults to the client's IP address.
    • customEvents Object It allows you to set the custom events which can be used to build your own analytics on top of analytics. Further, these events can be used to filter the analytics stats from the dashboard.
    • enableTelemetry Boolean When set to false, disable the telemetry. Defaults to true.

To customize the query execution

  • headers Object [optional] set custom headers to be sent with each server request as key/value pairs.

  • transformRequest Function Enables transformation of network request before execution. This function will give you the request object as the param and expect an updated request in return, for execution.

    transformRequest={request =>
            credentials: include,
  • transformResponse Function Enables transformation of search network response before
    rendering them. It is an asynchronous function which will accept an Elasticsearch response object as param and is expected to return an updated response as the return value.
    transformResponse={async elasticsearchResponse => {
        const ids = => item._id);
        const extraInformation = await getExtraInformation(ids);
        const hits = => {
            const extraInformationItem = extraInformation.find(
                otherItem => otherItem._id === item._id,
            return {

        return {
            hits: {

Note: transformResponse function is expected to return data in the following structure.

    // Elasticsearch hits response
    hits: {
        hits: [...],
        total: 100
    // Elasticsearch aggregations response
    aggregations: {

    took: 1

Advanced Usage

Although, react-native-searchbox API should be enough to build a powerful searchbox UI, if you need to access the SearchComponent instance for a particular component id for more advanced use-cases, then you can access it with the help of the react context API.

import { SearchContext } from '@appbaseio/react-native-searchbox';

class AdvancedComponent extends React.Component {
    static contextType = SearchContext;
    render() {
        return null;