> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sublay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Build community spaces with membership, moderation, rules, and optional chat

Spaces are community containers where users can gather, post content, and interact under customizable rules. Each space has its own membership system, permission levels, moderation tools, and optionally an integrated chat conversation.

> [!NOTE]
>
> **Requires the `spaces` bundle.** Spaces are only available when the `spaces` bundle is installed on your project (space-level chat additionally needs the `chat` bundle). See [Bundles](https://docs.sublay.io/v7/bundles.md) to add it.

## In This Section

> [card] [Provider & Hook](https://docs.sublay.io/v7/sdk/spaces/provider-and-hook.md)
>
> Load a space into context and access its state and operations

> [card] [Membership](https://docs.sublay.io/v7/sdk/spaces/membership.md)
>
> Join/leave spaces, approval workflows, role management

> [card] [Moderation](https://docs.sublay.io/v7/sdk/spaces/moderation.md)
>
> Approve or remove content, handle member and content reports

> [card] [Rules](https://docs.sublay.io/v7/sdk/spaces/rules.md)
>
> Create and display community rules for members

> [card] [Space Lists](https://docs.sublay.io/v7/sdk/spaces/space-lists.md)
>
> Browse and paginate spaces with filtering and sorting

## Core Architecture

Spaces follow the provider + hook pattern used throughout Sublay. Wrap your space UI with a `SpaceProvider` and access everything via `useSpace`.

```tsx theme={null}
import { SpaceProvider, useSpace } from "@sublay/react-js";

function SpacePage() {
  return (
    <SpaceProvider spaceId="space-uuid">
      <SpaceContent />
    </SpaceProvider>
  );
}

function SpaceContent() {
  const { space, isMember, canPost, joinSpace } = useSpace();

  if (!space) return <div>Loading...</div>;

  return (
    <div>
      <h1>{space.name}</h1>
      {!isMember && (
        <button onClick={joinSpace}>Join Space</button>
      )}
    </div>
  );
}
```

## Permission Model

Each space has two independent permission settings, which your app enforces:

* **`readingPermission`** — `"anyone"` or `"members"`. Who may read content.
* **`postingPermission`** — `"anyone"`, `"members"`, or `"admins"`. Who may post.

The v7 API stores both and reports them in the user's resolved permissions, but doesn't hide or refuse content because of them; see [Content inside a space](https://docs.sublay.io/v7/data-models/space.md#content-inside-a-space) and the [v8 rules](https://docs.sublay.io/v8/data-models/space.md#who-can-read-content).

When the current user is authenticated and is a member, `useSpace` exposes their resolved permissions (`canPost`, `canRead`, `canModerate`, `isAdmin`, `isModerator`).

Separately, each space has a **`visibility`** setting — `"public"` (default), `"unlisted"`, or `"private"` — that controls who can find and see the space, independent of the permission model above. `"unlisted"` hides a space from discovery and search but keeps it reachable by direct link; it is **not access control**. `"private"` hides the space, and the spaces under it, from everyone except its active members — it answers `404` like a nonexistent space and can't be joined. The content inside a space stays readable in v7 whatever its `visibility` and `readingPermission`; in v8, private spaces and `readingPermission: "members"` protect it too ([v8 Space data model](https://docs.sublay.io/v8/data-models/space.md#who-can-read-content)). See the [Space data model](https://docs.sublay.io/v7/data-models/space.md#visibility).

## Hierarchy

Spaces can be nested up to 10 levels deep. A child space is created by passing a `parentSpaceId` to `useCreateSpace`. Only admins of the parent space can create child spaces. Parent admins and moderators are automatically cascaded into new child spaces with their existing roles.

## What's Next

Start with the [Provider & Hook](https://docs.sublay.io/v7/sdk/spaces/provider-and-hook.md) to learn how to set up a space in your component tree, then explore membership and moderation features.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.