nick-vogel

payload blurhash

by nick-vogel
Media & images
v3
^3.0.0
MIT

Overview

Summary generated from the README

Adds a blurhash plugin that generates a small base64 WebP data URL for every new image upload and stores it on the upload document. It adds fields to targeted upload collections, with configurable resolution and an admin preview with a regenerate button. Requires Payload 3 and sharp as a peer dependency.

Features

  • Generates a base64 WebP placeholder on each new image upload
  • Stores the data URL on the upload document as a read-only field
  • Configurable horizontal and vertical resolution from 1 to 9
  • Admin sidebar preview with a Regenerate button
  • Authenticated regenerate endpoint that returns a new placeholder without saving
  • Can target specific upload collections or all of them, and can be disabled via option

Use cases

  • Show an instant blurred preview with next/image while full images load
  • Add placeholders to an existing media library by regenerating them from the admin
  • Render static blurred images on the frontend without extra requests

From the author

Payload CMS plugin for automatic blurhash generation on image uploads.

Installation

npm i @nlvogel/payload-blurhash

3

Stars

0

Forks

0

Open Issues

1 months ago

Last Updated

11

Weekly Downloads

v0.1.0

npm Version

44.0 KB

Unpacked Size

0

Dependencies

GitHub stars

3+2 since Sep 6

Show data
GitHub stars by day (UTC)
DateStars
Dec 5, 20263
Dec 4, 20263
Dec 3, 20263
Dec 2, 20262
Dec 1, 20262
Nov 30, 20262
Nov 29, 20262
Nov 28, 20262
Nov 27, 20262
Nov 26, 20262
Nov 25, 20262
Nov 24, 20262
Nov 23, 20262
Nov 22, 20262
Nov 21, 20262
Nov 20, 20262
Nov 19, 20262
Nov 18, 20262
Nov 17, 20262
Nov 16, 20262
Nov 15, 20262
Nov 14, 20262
Nov 13, 20262
Nov 12, 20262
Nov 11, 20262
Nov 10, 20262
Nov 9, 20262
Nov 8, 20262
Nov 7, 20262
Nov 6, 20262
Nov 5, 20262
Nov 4, 20262
Nov 3, 20261
Nov 2, 20261
Nov 1, 20261
Oct 31, 20261
Oct 30, 20261
Oct 29, 20261
Oct 28, 20261
Oct 27, 20261
Oct 26, 20261
Oct 25, 20261
Oct 24, 20261
Oct 23, 20261
Oct 22, 20261
Oct 21, 20261
Oct 20, 20261
Oct 19, 20261
Oct 18, 20261
Oct 17, 20261
Oct 16, 20261
Oct 15, 20261
Oct 14, 20261
Oct 13, 20261
Oct 12, 20261
Oct 11, 20261
Oct 10, 20261
Oct 9, 20261
Oct 8, 20261
Oct 7, 20261
Oct 6, 20261
Oct 5, 20261
Oct 4, 20261
Oct 3, 20261
Oct 2, 20261
Oct 1, 20261
Sep 30, 20261
Sep 29, 20261
Sep 28, 20261
Sep 27, 20261
Sep 26, 20261
Sep 25, 20261
Sep 24, 20261
Sep 23, 20261
Sep 22, 20261
Sep 21, 20261
Sep 20, 20261
Sep 19, 20261
Sep 18, 20261
Sep 17, 20261
Sep 16, 20261
Sep 15, 20261
Sep 14, 20261
Sep 13, 20261
Sep 12, 20261
Sep 11, 20261
Sep 10, 20261
Sep 9, 20261
Sep 8, 20261
Sep 7, 20261
Sep 6, 20261
npm weekly downloads

12+5 since Sep 6

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 5, 202612
Dec 4, 202614
Dec 3, 202614
Dec 2, 202614
Dec 1, 202622
Nov 30, 202638
Nov 29, 202635
Nov 28, 202652
Nov 27, 202650
Nov 26, 202651
Nov 25, 202650
Nov 24, 202640
Nov 23, 202624
Nov 22, 202625
Nov 21, 20265
Nov 20, 20264
Nov 19, 20265
Nov 18, 20266
Nov 17, 20266
Nov 16, 20266
Nov 15, 20268
Nov 14, 20268
Nov 13, 20268
Nov 12, 20265
Nov 11, 20264
Nov 10, 20263
Nov 9, 20264
Nov 8, 20263
Nov 7, 20263
Nov 6, 20264
Nov 5, 20266
Nov 4, 20266
Nov 3, 202619
Nov 2, 202619
Nov 1, 202618
Oct 31, 202619
Oct 30, 202618
Oct 29, 202616
Oct 28, 202616
Oct 27, 20264
Oct 26, 20264
Oct 25, 20266
Oct 24, 20265
Oct 23, 20265
Oct 22, 20267
Oct 21, 20267
Oct 20, 20266
Oct 19, 20265
Oct 18, 20266
Oct 17, 20266
Oct 16, 20266
Oct 15, 20264
Oct 14, 20264
Oct 13, 20264
Oct 12, 20264
Oct 11, 20264
Oct 10, 20264
Oct 9, 20264
Oct 8, 20264
Oct 7, 20264
Oct 6, 20265
Oct 5, 20265
Oct 4, 20261
Oct 3, 20262
Oct 2, 20262
Oct 1, 20262
Sep 30, 20262
Sep 29, 20261
Sep 28, 20261
Sep 27, 20262
Sep 26, 20264
Sep 25, 20267
Sep 24, 20267
Sep 23, 20267
Sep 22, 20268
Sep 21, 20269
Sep 20, 20268
Sep 19, 20265
Sep 18, 20262
Sep 17, 20262
Sep 16, 20264
Sep 15, 20264
Sep 14, 20263
Sep 13, 20263
Sep 12, 20264
Sep 11, 20264
Sep 10, 20265
Sep 9, 20264
Sep 8, 20266
Sep 7, 20266
Sep 6, 20267

Each point is npm's rolling 7-day download count.

Health Score

56/100Good

Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.

Badge for your README

Payload Directory health badge
Markdown
[![Payload Directory](https://payloaddirectory.dev/badge/1224146426-root.svg)](https://payloaddirectory.dev/plugins/1224146426-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1224146426-root"><img src="https://payloaddirectory.dev/badge/1224146426-root.svg" alt="Payload Directory"></a>
Updated Oct 22, 2026Created Apr 29, 2026Published Apr 29, 2026

README

payload-blurhash

A Payload CMS plugin that automatically generates a tiny base64 WebP placeholder ("blurhash") for image uploads. Use it to render an instant blurred preview while the full image loads — the same trick Next.js, Medium, and Unsplash use.

The placeholder is stored as a data:image/webp;base64,... string directly on the upload document, so your frontend can render it without an extra request.

Install

pnpm add @nlvogel/payload-blurhash
# or
npm install @nlvogel/payload-blurhash

sharp is a peer dependency. If you're already running Payload, you have it.

Usage

// payload.config.ts
import { buildConfig } from 'payload'
import { blurhashPlugin } from '@nlvogel/payload-blurhash'

export default buildConfig({
  plugins: [
    blurhashPlugin({
      // Optional — limit to specific upload collections.
      // Omit to apply to all upload-enabled collections.
      collections: ['media'],
    }),
  ],
})

The plugin adds the following fields to each targeted upload collection:

FieldTypeDescription
blurhashtext (read-only)The base64-encoded WebP data URL.
blurhashComponentXnumber (1–9)Horizontal resolution of the placeholder.
blurhashComponentYnumber (1–9)Vertical resolution of the placeholder.
blurhashPreviewuiSidebar preview with a "Regenerate" button.

A blurhash is generated on every new image upload, and re-generated whenever blurhashComponentX or blurhashComponentY change.

Options

blurhashPlugin({
  collections?: string[]    // upload collection slugs; omit = all
  componentX?: number       // default X resolution, 1–9 (default: 4)
  componentY?: number       // default Y resolution, 1–9 (default: 3)
  enabled?: boolean         // disable without uninstalling (default: true)
})

Rendering the placeholder

The value is already a base64 WebP data URL, so it drops straight into next/image as blurDataURL:

import Image from 'next/image'

<Image
  src={media.url}
  width={media.width}
  height={media.height}
  alt={media.alt ?? ''}
  placeholder="blur"
  blurDataURL={media.blurhash}
/>

Or use it as a plain <img> for a static blur:

<img
  src={media.blurhash}
  style={{ aspectRatio: `${media.width} / ${media.height}` }}
/>

Regenerate endpoint

The plugin registers POST /api/blurhash/regenerate for the in-admin "Regenerate" button. It requires an authenticated request and accepts:

{
  "id": "<doc id>",
  "collection": "<slug>",
  "componentX": 4,
  "componentY": 3
}

It returns { "blurhash": "data:image/webp;base64,..." } without persisting — saving the document writes the new value.

Compatibility

  • Payload ^3.0.0
  • Node ^18.20.2 || >=20.9.0
  • React ^18 || ^19

License

MIT © Nick Vogel

Similar plugins