Search SDK
The DocStar Search SDK adds your docs search to any website or web app. Users press Cmd/Ctrl + K, search your published docs, and can ask AI for an answer without leaving your product.
What you get
- A search window with live results from your published DocStar collection
- An Ask AI button for natural-language answers
- Three ways to open results: a side panel, a new tab or the current tab
- Keyboard shortcuts and arrow-key navigation
- Works with plain HTML, React, Vue, Angular and any other web framework
- Mobile-friendly layout
There's no backend to build. The SDK searches your DocStar collection directly.
Add it to your site
Add two script tags before the closing </body> tag. Replace your-collection-id with your collection's ID (you can find it in the collection's URL in DocStar, after /collection/).
<!-- Load the DocStar Search SDK -->
<script src="https://script.docstar.io/scripts/search-sdk/search-sdk.script.min.js"></script>
<!-- Configure it -->
<script>
window.DocStarSearch.configure({
collectionId: "your-collection-id",
openMode: "iframe",
debounceDelay: 300,
enableKeyboardShortcut: true,
minSearchLength: 2
});
</script>
Only published pages appear in results. See Publish Pages.
Options
| Option | Type | Default | Description |
|---|---|---|---|
collectionId |
string | (required) | The collection to search |
openMode |
string | (required) | How results open: "iframe" (side panel), "newTab" or "currentTab" |
debounceDelay |
number | 300 |
Milliseconds to wait after typing before searching |
enableKeyboardShortcut |
boolean | true |
Open search with Cmd/Ctrl + K |
minSearchLength |
number | 2 |
Characters needed before a search runs |
Open and close search from your code
window.DocStarSearch.open(); // open the search window
window.DocStarSearch.close(); // close it
React example
function SearchButton() {
const handleSearch = () => {
if (window.DocStarSearch) {
window.DocStarSearch.open();
}
};
return <button onClick={handleSearch}>Search docs</button>;
}
Load the two script tags once (for example in your main HTML file or layout). The same pattern works in Vue, Angular and other frameworks.
Ask AI
After results appear, users can click Ask AI to ask their question in plain language. An AI chat opens and answers using your docs, and users can ask follow-up questions in the same chat.
Keyboard shortcuts
| Keys | Action |
|---|---|
| Cmd/Ctrl + K | Open search (if enabled) |
| Up / Down arrows | Move through results |
| Enter | Open the highlighted result |
| Escape | Close the search window or the side panel |
Tips
- Use
"iframe"to keep users in your app while they read. Use"newTab"when your docs should open on their own site. - Raise
debounceDelayif your users type long queries, so fewer searches run while they type. - Add a visible Search button that calls
open(). Not everyone knows the keyboard shortcut.