The most direct way to populate Slash is to pass it a JSON document describing every item it should be able to find — pages, actions, or anything else you want searchable. This is one of several data sources Slash supports, and works well for small-to-medium sites where the item list is known ahead of time.
12345678910111213141516171819202122232425262728{ "items": [ { "label": "Pricing", "url": "/pricing", "category": "Pages", "keywords": ["cost", "plans", "billing"] }, { "label": "Documentation", "url": "/docs", "category": "Pages", "icon": "book-open" }, { "label": "New Document", "category": "Actions", "icon": "file-plus", "action": "create-doc" }, { "label": "Toggle Dark Mode", "category": "Actions", "icon": "moon", "action": "toggle-theme" } ]}labelrequiredstringThe text shown in results.urlstringNavigates on select when present.categorystringGroups items under a heading in results.keywordsstring[]Extra terms that match without appearing in the label.iconstringA Feather icon name shown next to the item.actionstringAn identifier dispatched to onSelect instead of navigating.Items with a url navigate directly. Items with an action instead call your onSelect handler with the item's action string, so you can wire up custom behavior — creating a document, toggling a setting, opening a modal — without leaving the page.
123456789101112131415import { Slash } from '@slash.tools/react'import items from './slash-items.json'
export function App() { return ( <Slash apiKey={process.env.SLASH_API_KEY} items={items.items} onSelect={(item) => { if (item.action === 'toggle-theme') toggleTheme() if (item.action === 'create-doc') createDocument() }} /> )}JSON config is static — it only changes when you redeploy. Pair it with Auto-Discovery or the Sitemap source below if you want Slash to stay current as pages are added without touching this file.