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

@sparticuz/chromium

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sparticuz/chromium

Chromium Binary for Serverless Platforms

  • 109.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
156K
decreased by-9.5%
Maintainers
1
Weekly downloads
 
Created

What is @sparticuz/chromium?

@sparticuz/chromium is an npm package that provides a pre-compiled version of Chromium, which is optimized for AWS Lambda and other serverless environments. It allows you to run headless Chromium in environments where installing Chromium from scratch would be impractical or impossible.

What are @sparticuz/chromium's main functionalities?

Launching Headless Chromium

This code demonstrates how to launch a headless Chromium browser using Puppeteer and the @sparticuz/chromium package. It navigates to a webpage and prints the title.

const chromium = require('@sparticuz/chromium');
const puppeteer = require('puppeteer-core');

(async () => {
  const browser = await puppeteer.launch({
    executablePath: await chromium.executablePath(),
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    headless: chromium.headless,
  });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());
  await browser.close();
})();

Taking Screenshots

This code demonstrates how to take a screenshot of a webpage using Puppeteer and the @sparticuz/chromium package. The screenshot is saved as 'example.png'.

const chromium = require('@sparticuz/chromium');
const puppeteer = require('puppeteer-core');

(async () => {
  const browser = await puppeteer.launch({
    executablePath: await chromium.executablePath(),
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    headless: chromium.headless,
  });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({ path: 'example.png' });
  await browser.close();
})();

PDF Generation

This code demonstrates how to generate a PDF of a webpage using Puppeteer and the @sparticuz/chromium package. The PDF is saved as 'example.pdf'.

const chromium = require('@sparticuz/chromium');
const puppeteer = require('puppeteer-core');

(async () => {
  const browser = await puppeteer.launch({
    executablePath: await chromium.executablePath(),
    args: chromium.args,
    defaultViewport: chromium.defaultViewport,
    headless: chromium.headless,
  });
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.pdf({ path: 'example.pdf', format: 'A4' });
  await browser.close();
})();

Other packages similar to @sparticuz/chromium

Keywords

FAQs

Package last updated on 07 Dec 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