<!--
{
  "availability" : [
    "MapKit JS: 5.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/SearchDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Type",
  "symbol" : {
    "kind" : "Type",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "type/mapkit.SearchDelegate"
  },
  "title" : "SearchDelegate"
}
-->

# SearchDelegate

An object or callback function the framework calls when performing a search or an autocomplete request.

```
type SearchDelegate<
    T extends SearchResponse | SearchAutocompleteResponse =
        | SearchResponse
        | SearchAutocompleteResponse,
> =
    | {
          searchDidError: (error: Error) => void;
          searchDidComplete: (result: SearchResponse) => void;
          autocompleteDidError: (error: Error) => void;
          autocompleteDidComplete: (result: SearchAutocompleteResponse) => void;
      }
    | ((error: Error | null, result: T | null) => void);
```

## Discussion

You can also pass an object to the [`search(query, options)`](/documentation/MapKitJS/Search/search) and [`autocomplete(query, options)`](/documentation/MapKitJS/Search/autocomplete) methods instead of a search delegate callback function. A delegate object can include the following methods:

- `searchDidComplete`. Upon successful completion of a search request, this method returns a data object that’s the same as the one that passes to the search callback function.
- `searchDidError`. The system calls this when the search request fails.
- `autocompleteDidComplete`. When an autocomplete request successfully completes, this method returns a `data` array that’s the same as the one that passes to the autocomplete callback function.
- `autocompleteDidError`. The system invokes this when an autocomplete request fails.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)