Skip to content
[Logo] [Logo]

Search

!Note: this page is auto-generated from docs/search.md.

Head Start provides out-of-the-box Search functionality in the shape of a search page and API endpoints to create your own search experience.

The search functionality uses DatoCMS Site Search under the hood.

Search page

A dedicated search page is available via /[locale]/search/. Its key features are:

Open Search is configured, so browsers and other applications can automatically detect the search page. See opensearch.xml(.ts) and references to it.

Search utilities

You can create your own enhanced search experience - like a search widget in the app header, client-side autosuggestions, async results, etc - using these available search utitilities:

Search lib function

import { datocmsSearch } from '@lib/datocms';

const { meta, results } = await datocmsSearch({
  locale: 'en',
  query: 'some text',
  fuzzy?: false, // defaults to true
});

Search JSON API endpoint

const { data } = await fetch('/api/search/?locale=en&query=some text');
const { meta, results } = data;

URL parameters:

Search HTML Partial endpoint

const response = await fetch('/{locale}/search/results.partial/?query=some text');
const resultsHtml = await response.text();

URL parameters: