Skip to content
  • Android
  • iOS
  • Web

Screen Capture

Capture the app or screen as an image and release the temporary result after use.

Examples

Quick start

Start capture from a user action. Browsers with screen capture support may prompt the user to choose a source.

nayan-ui/capture
import { capture } from 'nayan-ui/capture';

export async function inspectCapture() {
  if (!(await capture.isAvailable())) return null;
  const image = await capture.screen();
  try {
    return { width: image.width, height: image.height };
  } finally {
    await capture.release(image.uri);
  }
}

Share a temporary screenshot

Use from a user action where the platform supports sharing a captured URI.

nayan-ui/capture
import { capture } from 'nayan-ui/capture';
import { sharing } from 'nayan-ui/sharing';

export async function shareScreenshot() {
  if (!(await capture.isAvailable()) || !(await sharing.isAvailable())) return;
  const image = await capture.screen();
  try {
    await sharing.share({ uri: image.uri, title: 'Screenshot', mimeType: 'image/png', fileName: 'screenshot.png' });
  } finally {
    await capture.release(image.uri);
  }
}

Tags