Skip to Content
LYNKORIADocs

Screen sharing

Share a screen, window or tab inside a call, and show it to other participants.

Screen sharing works in any call where the participant may publish (every role except viewer). It uses the browser’s screen-capture picker.

Start and stop

await session.startScreenShare(); // opens the browser picker
await session.stopScreenShare();

Users can also stop sharing from the browser’s own “Stop sharing” bar; the published track ends automatically.

Show the current state with LiveKit’s hook:

import { useLocalParticipant } from '@livekit/components-react';
import type { CallSession } from '@lynkoria/client';

function ShareButton({ session }: { session: CallSession }) {
  const { isScreenShareEnabled } = useLocalParticipant();
  return (
    <button
      aria-pressed={isScreenShareEnabled}
      onClick={() =>
        isScreenShareEnabled ? session.stopScreenShare() : session.startScreenShare()
      }
    >
      {isScreenShareEnabled ? 'Stop sharing' : 'Share screen'}
    </button>
  );
}

Show shared screens

Include the screen-share source when you collect tracks:

import { useTracks } from '@livekit/components-react';
import { Track } from 'livekit-client';

const tracks = useTracks([
  { source: Track.Source.Camera, withPlaceholder: true },
  { source: Track.Source.ScreenShare, withPlaceholder: false },
]);

A common layout pins the screen-share track large and shows cameras in a strip; LiveKit’s FocusLayout and CarouselLayout help with this.

Errors and support

  • If the user cancels the picker, startScreenShare() rejects with NotAllowedError. Treat it as a cancel, not a failure.
  • Screen capture requires https:// (or localhost) and a desktop browser. Mobile browsers generally do not support it.
  • Sharing system audio depends on the browser and operating system.

On this page