← Back to docs

OpenSearch primer

Ship a search endpoint that browsers auto-discover.

OpenSearch is a tiny XML descriptor that tells browsers your site has a search engine. When a user visits, the browser offers to add your search to its omnibox — no extension required.

Descriptor XML

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
  <ShortName>Meridian</ShortName>
  <Description>Search Meridian docs</Description>
  <Url type="text/html"
       template="https://getnimbus.net/search?q={searchTerms}"/>
</OpenSearchDescription>

Host this at /opensearch.xml and link it from every page. Browsers pick it up automatically.

HTML link tag

<link rel="search"
      type="application/opensearchdescription+xml"
      title="Meridian"
      href="/opensearch.xml" />

Place this in your <head>. Chrome, Firefox, and Edge all respect it. Safari ignores OpenSearch but degrades gracefully.

Next.js route handler

// app/opensearch.xml/route.ts
export async function GET() {
  const xml = `<?xml version="1.0"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
  <ShortName>Meridian</ShortName>
  <Url type="text/html"
       template="https://getnimbus.net/search?q={searchTerms}"/>
</OpenSearchDescription>`
  return new Response(xml, {
    headers: { 'Content-Type': 'application/opensearchdescription+xml' }
  })
}

That is the entire feature. One XML file, one link tag, and your search is a first-class browser citizen.