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:
| Hook | Purpose |
|---|---|
useSearch | Search state and results |
useComparison | Product comparison |
useKeyboardShortcuts | Keyboard shortcuts (Cmd+K, Escape) |
useSwipeGesture | Touch gestures on mobile |
useChatPersistence | History persistence in localStorage |
useReducedMotion | Reduced motion preference detection |
useResponsive | Breakpoint detection (mobile/tablet/desktop) |
useFocusTrap | Focus 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:
| Shortcut | Action |
|---|---|
Cmd+K / Ctrl+K | Open/close widget |
/ | Open widget (outside inputs) |
Escape | Close widget |
Tab | Accept ghost text autocomplete |
Arrow Up/Down | Navigate suggestions |
Enter | Execute search |
Included touch gestures
The widget includes mobile gesture support:
| Gesture | Action |
|---|---|
| Swipe left | Remove filter/product from comparison |
| Swipe right | Apply suggestion |
| Long press | Add 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
- Callbacks - Respond to widget events
- Configuration - All available options
- JavaScript API - Public widget API