Skip to content

HTML / other CMS

Add cited search to any site that has a JavaScript build step, such as Hugo, Jekyll, Eleventy, Ghost or a Drupal theme, with one custom element.

Custom elementDeveloper preview@docslurp/sdk/widgetAll integrations
On this page

1Install

TerminalShell
# Needs @docslurp/sdk 0.2.0 or newer (0.1.x lacks these exports).
npm install @docslurp/sdk@^0.3.0

# Then register the element once in the browser:
# import { defineDocSlurpSearch } from '@docslurp/sdk/widget';

2Register the element

Bare npm imports need a bundler or import map, so register the widget in your existing build rather than pasting it into an unconfigured page.

site.jsJavaScript
import { defineDocSlurpSearch } from '@docslurp/sdk/widget';

defineDocSlurpSearch(); // call once, from your site's existing bundle

3Render it

Place the element in any template, using your template engine’s escaping for attribute values.

search.htmlHTML
<docslurp-search-box
  client-key="dslp_pub_…"
  workspace-id="product-docs"
  placeholder="Search the manuals…"
></docslurp-search-box>

Attributes

AttributeDefaultDescription
client-keyRequired*Browser key with the search scope, limited to your allowed websites.
workspace-id"default"Workspace slug, UUID or default.
api-url"https://docslurp.io"DocSlurp origin, for self-hosted deployments.
search-endpointnoneYour own server proxy. Replaces client-key, api-url and workspace-id.
placeholder"Search documents…"Input placeholder text.

* Not needed when search-endpoint is set.

Private content

For content behind a login, point the element at your own endpoint. Your server authenticates the visitor, picks the workspace they may read, searches with a server key and returns the results. The Next.js guide has a complete route handler.

search.htmlHTML
<!-- Your server receives POST { "q": "…" } and returns { "results": [...] }. -->
<docslurp-search-box search-endpoint="/api/search"></docslurp-search-box>

Styling

The element renders in a shadow root and shows passage text as plain text nodes, so source content can’t inject markup. Theme it with two custom properties:

site.cssCSS
docslurp-search-box {
  --docslurp-text: #e2e8f0;
  --docslurp-background: #0b1220;
}

Hand off to an agent

Working in a real codebase? Copy a prompt that tells a coding agent exactly what to change for HTML / other CMS: which entry point to use, the supported contract, and what to validate before shipping. It contains no keys or secrets.

Review agent instructions

Before switching traffic, run through the go-live checklist. Stuck? See troubleshooting.

Jump to