useAskContent lets users ask natural language questions and receive AI-generated answers grounded in your project’s actual content. The answer streams token by token via SSE, and once streaming completes, a list of source records is provided.
Usage Example
Parameters (ask function)
Limit the content types searched for context. Defaults to all types.
Only applies with
spaceId. When true, the context lookup also covers every space nested under it — the whole subtree at any depth — so you can ask across a community and all of its channels at once. Ignored without spaceId.Returns
The source records that were used as context for the answer. Populated after streaming completes.Content by users the signed-in user is block-edged with, comments on an entity whose author has blocked them, and comments their author deleted or a moderator removed, are never used as context or returned here.
The error if the request or the answer stream failed. Carries the server’s
code and status when it refused the request (for example "project/plan-required"). A SublayError.useAskContent uses the Fetch API with ReadableStream and TextDecoder for SSE. In React Native, install react-native-fetch-api, web-streams-polyfill@^3, react-native-polyfill-globals, and text-encoding, then call the targeted sub-polyfills once at app startup:polyfillGlobals(), which also pulls in the native react-native-get-random-values and forces a development-client rebuild. Pin web-streams-polyfill to v3 — v4 removed the ponyfill/es6 subpath react-native-polyfill-globals requires.Related
- useSearchContent — non-AI semantic search
- Search & AI overview

