Hook to get data about a space. You can use this hook to get space metadata and ids of channels in the space.

Imports

import { useSpace } from '@towns-protocol/react-sdk'

Examples

You can use this hook to display the data about a space:

import { useSpace } from '@towns-protocol/react-sdk'

const Space = ({ spaceId }: { spaceId: string }) => {
    const { data: space } = useSpace(spaceId)
    return <div>{space.metadata?.name || 'Unnamed Space'}</div>
}

Definition

function useSpace(
  spaceId: string,
  config?: ObservableConfig.FromObservable<Space>,
): ObservableValue<SpaceModel>

Source: useSpace

Parameters

spaceId

  • Type: string

The id of the space to get data about.

config

  • Type: ObservableConfig.FromObservable<Space>
  • Optional

Configuration options for the observable.

Return Type

The SpaceModel data.

ObservableValue<SpaceModel>