Skip to main content

Overview

Fetches the single Conversation that is tied to a Space. Each Space has exactly one conversation of type "space". Use this hook to retrieve the conversation ID before rendering message components.
Requires ChatProvider in the component tree.

Usage Example

import { useFetchSpaceConversation } from "@replyke/react-js";

function SpaceChatPanel({ spaceId }: { spaceId: string }) {
  const { conversation, loading } = useFetchSpaceConversation({ spaceId });

  if (loading) return <div>Loading...</div>;
  if (!conversation) return null;

  return <MessageList conversationId={conversation.id} />;
}

Props

spaceId
string
required
The ID of the space whose conversation to fetch.

Returns

conversation
Conversation | null
The Conversation associated with the space, or null while loading.
loading
boolean
true while the fetch is in progress.

Notes

  • The conversation is fetched on mount and stored in both local state and Redux.
  • For integration guidance, see Chat: Conversations.