Overview
useSpaceMentions provides autocomplete suggestion logic for #space-slug style mentions in text inputs. It tracks cursor position, detects mention triggers, and fetches matching spaces using debounced search.
Spaces must have a
slug set to be mentionable. This hook uses the # trigger by default.Usage Example
Parameters
string
required
The current text content of the editor.
(value: string) => void
required
Setter to update the content when a mention is selected.
() => void
required
Function to re-focus the editor after a mention is selected.
number
required
Current cursor position in the text.
boolean
required
Whether text is currently selected. Disables mention detection during selection.
string
Character that triggers mention detection. Defaults to
"#".number
Minimum characters after the trigger before search fires. Defaults to
3.number
Milliseconds to wait after the last keystroke before fetching. Defaults to
1000.Returns
boolean
Whether the mention autocomplete is currently active.
boolean
Whether suggestions are being fetched.
Space[]
Matching spaces to display as suggestions.
(space: Space) => void
Call this when a suggestion is selected. Replaces the trigger text with the space slug.
Mention[]
Accumulated list of all selected mentions (id, slug, type: “space”).
(space: Space) => void
Manually add a space to the mentions list.
() => void
Clear all mention state.

