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
Regex pattern (as a string) that the text after the trigger must match. Defaults to
"[\\w\\-\\u0080-\\uFFFF]+": ASCII letters, digits, underscores and hyphens, plus any character outside ASCII, so a name in any language matches. That covers everything a space slug can contain. The pattern is used without the u flag.Returns
Call this when a suggestion is selected. Replaces the trigger text with the space slug. The suggestions then stay closed until the text or the cursor position changes.

