Custom Autosuggest

Start of documentation content

By writing a small adaptor you can wire up Formally to your own AutoSuggest API.

Use of onAutoSuggest

import { Formally } from 'formally';

<Formally
  onAutoSuggest={async ({ input, node, abortControllerSignal, locale }) => {
    // send requests to your own API
    // const response = await fetch(
    //   `https://example.com/api/auto-suggest?search=${input}`,
    // );
    // const searchResults = await response.json();

    return [
      { id: 'id', labelHtml: 'option 1', locale: 'en' },
      { id: 'id2', labelHtml: 'option 2', locale: 'en' },
    ];
  }}
/>;