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
The current text content of the editor.
Setter to update the content when a mention is selected.
Function to re-focus the editor after a mention is selected.
Current cursor position in the text.
Whether text is currently selected. Disables mention detection during selection.
Character that triggers mention detection. Defaults to
"#".Minimum characters after the trigger before search fires. Defaults to
3.Milliseconds to wait after the last keystroke before fetching. Defaults to
1000.Returns
Whether the mention autocomplete is currently active.
Whether suggestions are being fetched.
Matching spaces to display as suggestions.
Call this when a suggestion is selected. Replaces the trigger text with the space slug.
Accumulated list of all selected mentions (id, slug, type: “space”).
Manually add a space to the mentions list.
Clear all mention state.

