Poseidonas

payload barcodes

by Poseidonas
Stores & catalogs
v3
>=3.88 <4
MIT

Overview

Summary generated from the README

Adds a barcode and QR code to products in selected collections, drawn from a source field chosen in an admin settings global. An afterChange hook records the value and format, and a print endpoint returns an HTML page of labels. Requires Payload 3.88 or newer and the official ecommerce plugin; React is optional and only needed for the print buttons.

Features

  • Code 128, EAN-13 and QR encoders built in with no runtime dependencies
  • Source field selected in an admin settings global
  • Code value recorded on save, indexed and searchable
  • Print endpoint renders one or many labels on a single page
  • Optional QR URL template that inserts the code value
  • Optional client entry with Print Barcode and Print QR Code buttons

Use cases

  • Print SKU barcode labels for a batch of products from the Payload admin
  • Generate QR codes that link to product pages for shelf or packaging labels
  • Add scannable EAN-13 codes to products in a Payload ecommerce store

From the author

Barcodes and QR codes for Payload products: pick the field, get a printable code on every item, with no runtime dependencies.

Installation

npm i payload-barcodes

1

Stars

0

Forks

0

Open Issues

2 weeks ago

Last Updated

9

Weekly Downloads

v1.0.1

npm Version

49.8 KB

Unpacked Size

0

Dependencies

GitHub stars

10 since Sep 7

Show data
GitHub stars by day (UTC)
DateStars
Dec 6, 20261
Dec 5, 20261
Dec 4, 20261
Dec 3, 20261
Dec 2, 20261
Dec 1, 20261
Nov 30, 20261
Nov 29, 20261
Nov 28, 20261
Nov 27, 20261
Nov 26, 20261
Nov 25, 20261
Nov 24, 20261
Nov 23, 20261
Nov 22, 20261
Nov 21, 20261
Nov 20, 20261
Nov 19, 20261
Nov 18, 20261
Nov 17, 20261
Nov 16, 20261
Nov 15, 20261
Nov 14, 20261
Nov 13, 20261
Nov 12, 20261
Nov 11, 20261
Nov 10, 20261
Nov 9, 20261
Nov 8, 20261
Nov 7, 20261
Nov 6, 20261
Nov 5, 20261
Nov 4, 20261
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
npm weekly downloads

130 since Sep 7

Show data
npm weekly downloads by day (UTC)
DateWeekly downloads
Dec 6, 202613
Dec 5, 202610
Dec 4, 202611
Dec 3, 202611
Dec 2, 202615
Dec 1, 202617
Nov 30, 202618
Nov 29, 202619
Nov 28, 202627
Nov 27, 202634
Nov 26, 2026213
Nov 25, 2026208
Nov 24, 2026205
Nov 23, 2026204
Nov 22, 2026201
Nov 21, 2026192
Nov 20, 2026183
Nov 19, 20264
Nov 18, 20264
Nov 17, 20266
Nov 16, 20266
Nov 15, 20263
Nov 14, 20264
Nov 13, 20264
Nov 12, 20264
Nov 11, 20265
Nov 10, 20264
Nov 9, 20265
Nov 8, 20268
Nov 7, 20268
Nov 6, 20268
Nov 5, 202610
Nov 4, 20269
Nov 3, 20269
Nov 2, 20269
Nov 1, 20266
Oct 31, 20265
Oct 30, 20265
Oct 29, 20262
Oct 28, 20262
Oct 27, 20261
Oct 26, 20262
Oct 25, 20262
Oct 24, 20262
Oct 23, 20262
Oct 22, 20265
Oct 21, 20265
Oct 20, 20265
Oct 19, 20264
Oct 18, 20265
Oct 17, 20265
Oct 16, 20265
Oct 15, 20264
Oct 14, 20264
Oct 13, 20264
Oct 12, 20263
Oct 11, 20264
Oct 10, 20264
Oct 9, 20264
Oct 8, 20264
Oct 7, 20264
Oct 6, 20265
Oct 5, 20266
Oct 4, 20265
Oct 3, 20266
Oct 2, 20268
Oct 1, 20266
Sep 30, 20266
Sep 29, 20265
Sep 28, 20264
Sep 27, 20264
Sep 26, 20266
Sep 25, 20264
Sep 24, 20265
Sep 23, 20265
Sep 22, 20267
Sep 21, 20268
Sep 20, 202610
Sep 19, 20267
Sep 18, 20268
Sep 17, 20269
Sep 16, 202611
Sep 15, 202610
Sep 14, 202611
Sep 13, 20268
Sep 12, 20268
Sep 11, 20269
Sep 10, 20269
Sep 9, 20269
Sep 8, 20269
Sep 7, 202613

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

Health Score

70/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/1342020689-root.svg)](https://payloaddirectory.dev/plugins/1342020689-root)
HTML
<a href="https://payloaddirectory.dev/plugins/1342020689-root"><img src="https://payloaddirectory.dev/badge/1342020689-root.svg" alt="Payload Directory"></a>
Updated Nov 17, 2026Created Aug 21, 2026Published Nov 17, 2026

README

payload-barcodes

npm node license payload ecommerce

Gives every Payload product a barcode and a QR code, drawn from a field you choose, on a printable page that is black on white and nothing else. The encoders are part of this package: no runtime dependencies, no image service, no external call.

  • Code 128, EAN-13 and QR written from the specification, not wrapped from a library
  • The shop chooses which field holds the code, in the admin panel
  • Filled in automatically on every save, and searchable
  • One page for a single label or for a whole selection, ready for the printer
  • The main entry imports no React at all

Compatibility

RequirementVersionDeclared as
payload>=3.88 <4peer dependency
@payloadcms/plugin-ecommerce>=3.88 <4peer dependency
react>=19 <20optional peer dependency, only for the print buttons
Node>=20engines

The floor is the version this package was actually tested against. Verified end to end on Payload 3.88.0 with the official ecommerce plugin on PostgreSQL.

Install

Requires Payload 3.88 or newer and @payloadcms/plugin-ecommerce 3.88 or newer.

pnpm add payload-barcodes
import { barcodesPlugin } from 'payload-barcodes'

export default buildConfig({
  plugins: [
    barcodesPlugin({
      collections: ['products'],
    }),
  ],
})

Then open Barcodes in the admin panel and name the field that holds the code, for example sku. Nothing is generated until you do.

What was measured

Measured on 21 August 2026 against @payloadcms/plugin-ecommerce 3.88.0 and the npm registry.

QuestionAnswer
Does the ecommerce plugin produce a barcode or a QR code?No. Neither term appears in it
Is there a barcode or QR plugin for Payload?None on the registry
Do products carry a code field?No

The encoders are verified, not assumed

Every QR code this package draws is read back by an independent decoder in the test suite. The sweep covers versions 1 to 10 at all four error correction levels:

723 codes encoded, 723 decoded correctly, 0 failures

That check runs in CI on every push, so a regression in the encoder cannot pass unnoticed.

The barcodes are checked against published article numbers. 590123412345 gives check digit 7, 400638133393 gives 1, 978020137962 gives 4, 501234567890 gives 0. An EAN-13 pattern is 95 modules wide with guards at 101, 01010 and 101; a Code 128 pattern is eleven modules per symbol plus a thirteen module stop.

Verified in a live install

TestResult
Admin names slug as the source fieldCode filled in on save, indexed and searchable
A source value the CMS transformsRecorded value matches the stored value, not the submitted one
QR set to a URL templatePage scanned back as https://shop.example/p/walnut-table-99
Print pageHTML, #000 and #fff only, prints on load
Several ids at onceOne page, one label per product, no label split across pages
Value that is not a valid EAN-13Recorded with a plain explanation instead of a broken drawing
Print endpoint without a token403

How it works

The plugin adds three things: a code group on each named collection, a settings global, and one endpoint.

Recording. An afterChange hook reads the source field and stores the value, the symbology, and an explanation when the value cannot be drawn. It runs after the write on purpose: a field hook may still transform the value, a slug being the usual case, and a code that does not match the field it came from is worse than none.

The hook writes only when something changed, and marks the request so its own save cannot re-enter it.

Drawing. The images are never stored. Both codes are drawn when the page is requested, so changing a setting changes every label immediately and nothing in your database goes stale.

Printing. The endpoint returns one complete HTML page holding every label, with page-break-inside: avoid so a label is never split. It opens the print dialog on load. There are no colours, no images and no scripts beyond that one call.

Options

OptionDefaultMeaning
collectionsrequiredCollections that get a code, by slug
disabledfalseStops recording, leaves fields and settings in place
fieldName'barcode'Name of the field group holding the code
settingsSlug'barcodes'Slug of the settings global

Settings

SettingMeaning
Source fieldField read for the code, for example sku. Nothing happens until this is set
FormatCode 128 for any printable ASCII, or EAN-13 for thirteen digit article numbers
QR code carriesThe same value, or a URL built from it
URL templateWhere {value} is replaced by the code, URL encoded
Print the value under the codeAdds the value in monospace under the bars

What it adds to your database

WhereFieldNotes
each named collectionbarcode groupvalue (indexed), format, and error when the value cannot be drawn
new global barcodessource field, format, QR source, URL template, captionAppears in the admin menu under Ecommerce

The settings are an ordinary Payload global, which is why they reach the menu without this package shipping an admin component.

Printing

GET /api/barcodes/print?collection=products&id=42&type=barcode
GET /api/barcodes/print?collection=products&id=1,2,3&type=qr

Requires an authenticated user and reads each document with the caller's own access rights. type is barcode or qr. Several ids give one page with one label each.

The two buttons

The endpoint is enough on its own. If you want the buttons inside a document, import them from the separate client entry:

import { PrintButtons } from 'payload-barcodes/client'

<PrintButtons collection="products" id={id} />

They render exactly Print Barcode and Print QR Code, with no styling of their own beyond spacing, so they inherit your admin theme.

This is a deliberate split. The main entry contains no React, which is what keeps the package on the part of Payload's surface that survives minor releases. The buttons are opt in, and if they ever break, the printing itself does not.

Honest limits

QR codes go up to version 10. That is 271 bytes at level L, 213 at M. It covers an article number, a SKU or a product URL comfortably. A longer value is refused with a clear message rather than silently truncated.

Code 128 uses set B only. Printable ASCII from space to tilde. Set A control characters and set C numeric compression are not implemented, so a long numeric code is wider than it strictly needs to be. Anything outside set B, Greek included, is refused with an explanation.

EAN-13 is validated, not corrected. A value that is not thirteen digits with a matching check digit is recorded with an error and no barcode is drawn. completeEan13 is exported if you want to add the check digit yourself. The QR code is still drawn in that case.

Recording costs a second write on the first save. The hook runs after the document is written, so a new document is saved twice: once by you, once to record the code. Later saves write only when the value actually changed.

The print page carries no fonts of its own. It uses the system stack, so a label printed on one machine may be a hair wider than on another. The codes themselves are vector and exact.

Codes are not checked for uniqueness. Two products may carry the same value if the source field allows it. Put a unique index on your source field if that matters.

License

MIT. Copyright George Vasiliades, https://github.com/Poseidonas

Similar plugins