Front-End Collaboration API

Last modified by Manuel Leduc on 2026/02/05 17:22

Content

Reference

CollaborationInitializer

/**
 * Holds properties of an collaboration. It's provider, the document held by the provider, and a provide resolved on
 * the initialized is ready.
 * @since 0.20
 */
type CollaborationInitializer = {
  /**
   * The provider, can be of arbitrary type.
   */
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  provider: any;
  /**
   * The yjs document held by the provider.
   */
  doc: Doc;
  /**
   * The promise must be resolved once the provider is connected and ready.
   */
  initialized: Promise<unknown>;
};

CollaborationManager

/**
 * The manager for a given collaboration provider (e.g., hocuspocus, or y-websocket).
 * @since 0.20
 */
interface CollaborationManager {
  /**
   * A lazy initializer for a collaboration initializer. We proceed that way to allow the collaboration provider to
   * be resolved and assigned outside the editor, but to be effectively initialized inside the editor, where
   * access to the internal editor structure is available.
   */
  get(): Promise<() => CollaborationInitializer>;

  /**
   * The current status.
   */
  status(): Ref<Status>;

  /**
   * The list of currently connected users.
   */
  users(): Ref<User[]>;
}

CollaborationManagerProvider

/**
 * Dynamically resolves a CollaborationManager based on the configuration.
 *
 * @since 0.20
 */
export interface CollaborationManagerProvider {
  /**
   * @returns the resolved collaboration manager
   */
  get(): CollaborationManager;
}

User

/**
 * Mandatory information for a user connected to a realtime session.
 *
 * @since 0.20
 */
export type User = {
  user: {
    name: string;
    color: string;
  };
  clientId: string;
};

Get Connected