npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@nicacoder/webscreenshots

v0.0.1

Published

A simple CLI tool for capturing websites screenshots.

Downloads

2

Readme

Webscreenshots

A simple CLI tool to capture screenshots of websites at different viewports.
Supports crawling, full-page capture, and custom configuration.


✨ Features

  • Capture full-page or viewport-specific screenshots
  • Supports multiple viewports
  • Crawl your site to auto-discover internal pages
  • Custom image format
  • Headless or non-headless mode
  • Authentication Support (Basic, Cookie, Form, Token)

📦 Installation

Use via npx (no global install required):

npx @nicacoder/webscreenshots --url https://example.com

Or add to your project:

npm install --save-dev @nicacoder/webscreenshots

🚀 Usage

Basic CLI Usage

npx @nicacoder/webscreenshots --url https://example.com

⚙️ Configuration

You can configure Webscreenshots in several ways:

  1. CLI Arguments – Pass options directly when running the CLI, e.g. --url https://example.com.
  2. Configuration File – Provide a .json config file with all your settings.
  3. Environment Variables – Set environment variables directly or via a .env file.

The precedence order is: CLI Arguments > Environment Variables > Configuration File

That means CLI arguments override environment variables, which in turn override configuration file settings.

Using a Configuration File

Create a webscreenshots.json config file with your settings, for example:

{
  "url": "https://example.com",
  "outputDir": "./screenshots",
  "outputPattern": "{host}/{viewport}/{host}-{viewport}-{route}-{timestamp}.{ext}",
  "routes": ["/", "/products", "/contact"],
  "browserOptions": {
    "headless": true,
    "args": ["--no-sandbox"]
  },
  "captureOptions": {
    "fullPage": true,
    "imageType": "jpeg",
    "quality": 80
  },
  "viewports": [
    {
      "name": "mobile",
      "width": 375,
      "height": 812
    },
    {
      "name": "desktop",
      "width": 1440,
      "height": 900
    }
  ],
  "crawl": true,
  "crawlOptions": {
    "crawlLimit": 30,
    "excludeRoutes": ["/admin"],
    "dynamicRoutesLimit": 5
  },
  "retryOptions": {
    "maxAttempts": 3,
    "delayMs": 1000
  }
}

Run the CLI with the config file:

npx @nicacoder/webscreenshots --config ./webscreenshots.json

Using Environment Variables

You can configure Webscreenshots by setting environment variables. For example:

WEBSCREENSHOTS__URL=https://example.com WEBSCREENSHOTS__OUTPUTDIR=./screenshots npx @nicacoder/webscreenshots

Or by defining an .env file:

WEBSCREENSHOTS__URL=https://example.com
WEBSCREENSHOTS__OUTPUTDIR=custom-screenshots
WEBSCREENSHOTS__CAPTUREOPTIONS__FULLPAGE=true
WEBSCREENSHOTS__CAPTUREOPTIONS__IMAGETYPE=jpeg
WEBSCREENSHOTS__CAPTUREOPTIONS__QUALITY=80
WEBSCREENSHOTS__BROWSEROPTIONS__HEADLESS=true

The CLI will automatically use the .env file if present. You can use the provided .env.example file as a starting point by copying it to .env and modifying the values as needed.


For full details on all available configuration options, their CLI flags, config file keys, and environment variable equivalents, see the CONFIGURATION.md file.


📁 Output Structure

Screenshots are saved inside folders by site and viewport name, and filenames follow a customizable pattern.

Folder Structure

screenshots/
├── example-com/
│   ├── desktop/
│   │   ├── example-com-desktop-home.png
│   │   └── example-com-desktop-docs-about.png
│   └── mobile/
│       ├── example-com-mobile-contact.png
│       └── example-com-mobile-products.png
└── another-site-com/
    └── desktop/
        └── another-site-com-desktop-home.png

Filename Pattern

By default, files are named using this pattern:

{host}/{viewport}/{host}-{viewport}-{route}.{ext}
  • {host} — Sanitized domain name (dots replaced with dashes, e.g. example.comexample-com)
  • {viewport} — Viewport name (lowercased, spaces replaced with dashes)
  • {route} — URL path segments joined by dashes (/docs/aboutdocs-about)
  • {ext} — File extension matching the image format (png, jpeg, or webp)

You can customize the pattern in your config or CLI options, including adding timestamps:

{host}/{viewport}/{host}-{viewport}-{route}-{timestamp}.{ext}

Where {timestamp} is an ISO timestamp safe for filenames (colons and dots replaced with dashes).


🔐 Authentication

Webscreenshots supports various authentication methods to handle sites requiring login or tokens, including:

  • Basic Authentication
  • Cookie-based Authentication
  • Form-based Authentication
  • Token-based Authentication

You can configure authentication via environment variables. See the AUTHENTICATION.md file for full details and examples.


🛠 Tooling

This project is built using:

  • Node.js – Runtime environment
  • TypeScript – Static type checking
  • Puppeteer – Headless browser automation for capturing screenshots
  • Yargs – CLI argument parsing
  • Ajv – JSON Schema validator for configuration files

📄 License

This project is licensed under the Apache License 2.0. See the LICENSE file for details.