Socket
Book a DemoInstallSign in
Socket

next-squoosh

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-squoosh

A React image optimization component with automatic WebP conversion and compression

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

Next.js Squoosh Image Optimizer

A Next.js plugin that optimizes images at build time using Squoosh library.

Features

  • 🖼️ Image optimization at build time using Squoosh
  • 🚀 Automatic optimization of images in specified directories
  • 📱 Support for multiple output formats (WebP, AVIF)
  • 🎛️ Configurable quality and format options
  • 🛠️ Seamless integration with Next.js build process

Installation

npm install next-squoosh
# or
yarn add next-squoosh
# or
pnpm add next-squoosh

Usage

Add the plugin to your Next.js configuration:

// next.config.js
const { withSquooshOptimizer } = require('next-squoosh');

module.exports = withSquooshOptimizer({
  // Your Next.js config
}, {
  // Optional: Configure the optimizer
  sourceDir: 'public/assets', // Directory containing source images
  outputDir: 'public/optimized', // Directory for optimized images
  formats: ['webp', 'avif'], // Output formats
  quality: 75, // Quality level (0-100)
});

Configuration Options

OptionTypeDefaultDescription
sourceDirstring'public/assets'Directory containing source images to optimize
outputDirstring'public/optimized'Directory where optimized images will be saved
formatsstring[]['webp']Array of output formats ('webp', 'avif')
qualitynumber75Quality level for optimization (0-100)

How It Works

  • During the Next.js build process, the plugin scans the specified source directory for images
  • Each image is processed using Squoosh to create optimized versions in the specified formats
  • Optimized images are saved to the output directory with format and quality information in the filename
  • The original Next.js image optimization is disabled to prevent double optimization

Example

Given an image at public/assets/hero.jpg, the plugin will create:

  • public/optimized/hero-webp-q75.webp
  • public/optimized/hero-avif-q75.avif (if AVIF format is enabled)

License

MIT

Keywords

react

FAQs

Package last updated on 18 May 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.