A lightweight, framework-agnostic web screenshot SDK with built-in annotation tools. Capture any region of the page and annotate it with pen, arrow, text, shapes, and mosaic β all from a simple API call.
Warning
This project is under active development. APIs may change.
- Region capture β drag to select any area on the page
- Multiple capture modes β DOM snapshot (
snapdom), screen recording (media), andhtmlInCanvas(Chrome 148+) - Annotation tools β pen, arrow, line, rectangle, ellipse, text box, and mosaic
- Customizable β configurable colors, sizes, line widths, font sizes per tool
- Export options β PNG, JPEG, or WebP with quality control
- Dark / Light / Auto theme support
- Tiny runtime β built on Preact, bundled into the output, no extra dependency for consumers
- Zero framework lock-in β works in any web app via vanilla JS API
git clone https://github.com/RadiumAg/js-screenshot.git
cd js-screenshot
pnpm install
pnpm buildimport ScreenShot from 'js-screenshot';
import 'js-screenshot/style';
const screenshot = new ScreenShot({
mode: 'snapdom',
theme: 'auto',
exportFormat: 'image/png',
quality: 0.92,
});
const result = await screenshot.shot();Calling shot() opens the capture overlay. The user selects a region, optionally annotates, and clicks save. The returned promise resolves with the captured image data.
interface ScreenShotOptions {
mode?: 'snapdom' | 'media' | 'htmlInCanvas';
theme?: 'dark' | 'light' | 'auto';
afterFinished?: () => void;
tools?: ToolsConfig;
exportFormat?: 'image/png' | 'image/jpeg' | 'image/webp';
quality?: number;
filename?: string;
}const screenshot = new ScreenShot({
tools: {
pen: { color: '#ff0000', lineWidth: 3 },
arrow: { color: '#00ff00', lineWidth: 2, lineType: 'arrow' },
textBox: { fontSize: 16, fontFamily: 'Arial', color: '#000' },
mosaic: { blockSize: 10, brushSize: 20 },
rect: { color: '#0000ff', lineWidth: 2 },
ellipse: { color: '#ff00ff', lineWidth: 2 },
line: { color: '#333', lineWidth: 2 },
},
});| Method | Description |
|---|---|
shot() |
Opens the capture overlay and returns a Promise with the result |
destroy() |
Manually destroys the screenshot instance and cleans up DOM |
The instance auto-destroys after capture completes or errors. You can also call destroy() manually.
<link rel="stylesheet" href="./dist/iife/screen-shot.css">
<script src="./dist/iife/screen-shot.js"></script>
<script>
const screenshot = new ScreenShot({ mode: 'snapdom' });
screenshot.shot().then(result => console.log(result));
</script>pnpm install
pnpm dev # dev server with playground
pnpm build # production build (esm + cjs + iife)
pnpm lint:fix # lint and auto-fix- Preact β lightweight UI rendering
- Zustand β state management
- @zumer/snapdom β DOM-to-canvas snapshot
- Rollup β bundler (ESM, CJS, IIFE outputs)
- TypeScript + CSS Modules