Skip to main content

Internal Hooks

Read-only reference

This page documents internal hooks used by the widget. These hooks are NOT accessible from the public NeuroonWidget API. This information is for reference only to understand how the widget works internally.

Hooks Architecture

The widget uses Preact hooks internally to manage:

HookPurpose
useSearchSearch state and results
useComparisonProduct comparison
useKeyboardShortcutsKeyboard shortcuts (Cmd+K, Escape)
useSwipeGestureTouch gestures on mobile
useChatPersistenceHistory persistence in localStorage
useReducedMotionReduced motion preference detection
useResponsiveBreakpoint detection (mobile/tablet/desktop)
useFocusTrapFocus trap in modals

Why aren't they public?

The widget loads as a script that only exposes window.NeuroonWidget:

// THIS is all you can use:
NeuroonWidget.init({ ... })
NeuroonWidget.getInstance()
NeuroonWidget.destroy()

// THIS doesn't work (hooks are internal):
// import { useKeyboardShortcuts } from '@neuroon/widget' ❌

Available keyboard shortcuts

Although you can't use the hook directly, the widget includes these shortcuts:

ShortcutAction
Cmd+K / Ctrl+KOpen/close widget
/Open widget (outside inputs)
EscapeClose widget
TabAccept ghost text autocomplete
Arrow Up/DownNavigate suggestions
EnterExecute search

Included touch gestures

The widget includes mobile gesture support:

GestureAction
Swipe leftRemove filter/product from comparison
Swipe rightApply suggestion
Long pressAdd product to comparison

Customization

To customize widget behavior, use configuration options:

NeuroonWidget.init({
container: '#neuroon-search',
token: 'YOUR_TOKEN',

// Use callbacks to respond to events
callbacks: {
onSearch: (query) => { ... },
onResultClick: (product) => { ... },
onFilterChange: (filters) => { ... },
},

// Customize translations
translations: {
search: { placeholder: 'Search...' },
},

// Customize styles
styles: {
primary: '#6366f1',
},
});

Next steps