Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@xata.io/screenshot

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xata.io/screenshot

A zero-dependency browser-native way to take screenshots powered by the native web MediaDevices API.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
747
decreased by-13.54%
Maintainers
3
Weekly downloads
 
Created
Source

Logo @xata.io/screenshot

This tool uses native browser APIs to take screenshots of a given web page, tab, window, or the user's entire screen.

Demos

Pick your preference. You can easily learn about this project in the following ways:

  • Watch an explainer on YouTube.
  • See it in action on CodeSandbox.
  • Read about the details at the Xata Blog.

Usage

First, you'll want to install it:

npm install @xata.io/screenshot

Then, you can add it to your app and use it like so:

import { takeScreenshot, checkIfBrowserSupported } from "@xata.io/screenshot";

/**
 * Only do this if your browser supports it.
 * To check, visit https://caniuse.com/mdn-api_mediadevices_getdisplaymedia
 */
if (checkIfBrowserSupported()) {
  takeScreenshot().then((screenshot) => {
    /**
     * This is a base64-encoded string representing your screenshot.
     * It can go directly into an <img>'s `src` attribute, or be sent to a server to store.
     */
    console.log(screenshot);
  });
}

Options

takeScreenshot accepts a few options to help you customize the user flow and the resulting image. These are:

OptionDescriptionRequiredDefault Value
qualityThe quality of the final image on a scale of 0 to 1. 0 is lowest quality, 1 is highest.nope.7
onCaptureStartAn async function that does stuff when the capture starts. You'll usually want to hide any modals or anything here.nope
onCaptureEndAn async function that does stuff after capture ends. This is usually when you'll want to clean up.nope
typeWhat kind of image do we want? Possible values are "image/jpeg" and "image/png".nope"image/jpeg"
soundEffectURLWhy not play a little camera click sound effect when taking a screenshot?nope-

Contributing

You're always welcome to open an issue if you encounter any, or even better, open a PR directly to solve issues. We don't (yet) have more contributing guidelines than this because the project is quite small. This may change as things develop.

Made with ❤️ in Berlin.

Keywords

FAQs

Package last updated on 05 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc