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.
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-barcodes1
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
10 since Sep 7
| Date | Stars |
|---|---|
| Dec 6, 2026 | 1 |
| Dec 5, 2026 | 1 |
| Dec 4, 2026 | 1 |
| Dec 3, 2026 | 1 |
| Dec 2, 2026 | 1 |
| Dec 1, 2026 | 1 |
| Nov 30, 2026 | 1 |
| Nov 29, 2026 | 1 |
| Nov 28, 2026 | 1 |
| Nov 27, 2026 | 1 |
| Nov 26, 2026 | 1 |
| Nov 25, 2026 | 1 |
| Nov 24, 2026 | 1 |
| Nov 23, 2026 | 1 |
| Nov 22, 2026 | 1 |
| Nov 21, 2026 | 1 |
| Nov 20, 2026 | 1 |
| Nov 19, 2026 | 1 |
| Nov 18, 2026 | 1 |
| Nov 17, 2026 | 1 |
| Nov 16, 2026 | 1 |
| Nov 15, 2026 | 1 |
| Nov 14, 2026 | 1 |
| Nov 13, 2026 | 1 |
| Nov 12, 2026 | 1 |
| Nov 11, 2026 | 1 |
| Nov 10, 2026 | 1 |
| Nov 9, 2026 | 1 |
| Nov 8, 2026 | 1 |
| Nov 7, 2026 | 1 |
| Nov 6, 2026 | 1 |
| Nov 5, 2026 | 1 |
| Nov 4, 2026 | 1 |
| Nov 3, 2026 | 1 |
| Nov 2, 2026 | 1 |
| Nov 1, 2026 | 1 |
| Oct 31, 2026 | 1 |
| Oct 30, 2026 | 1 |
| Oct 29, 2026 | 1 |
| Oct 28, 2026 | 1 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 1 |
| Oct 25, 2026 | 1 |
| Oct 24, 2026 | 1 |
| Oct 23, 2026 | 1 |
| Oct 22, 2026 | 1 |
| Oct 21, 2026 | 1 |
| Oct 20, 2026 | 1 |
| Oct 19, 2026 | 1 |
| Oct 18, 2026 | 1 |
| Oct 17, 2026 | 1 |
| Oct 16, 2026 | 1 |
| Oct 15, 2026 | 1 |
| Oct 14, 2026 | 1 |
| Oct 13, 2026 | 1 |
| Oct 12, 2026 | 1 |
| Oct 11, 2026 | 1 |
| Oct 10, 2026 | 1 |
| Oct 9, 2026 | 1 |
| Oct 8, 2026 | 1 |
| Oct 7, 2026 | 1 |
| Oct 6, 2026 | 1 |
| Oct 5, 2026 | 1 |
| Oct 4, 2026 | 1 |
| Oct 3, 2026 | 1 |
| Oct 2, 2026 | 1 |
| Oct 1, 2026 | 1 |
| Sep 30, 2026 | 1 |
| Sep 29, 2026 | 1 |
| Sep 28, 2026 | 1 |
| Sep 27, 2026 | 1 |
| Sep 26, 2026 | 1 |
| Sep 25, 2026 | 1 |
| Sep 24, 2026 | 1 |
| Sep 23, 2026 | 1 |
| Sep 22, 2026 | 1 |
| Sep 21, 2026 | 1 |
| Sep 20, 2026 | 1 |
| Sep 19, 2026 | 1 |
| Sep 18, 2026 | 1 |
| Sep 17, 2026 | 1 |
| Sep 16, 2026 | 1 |
| Sep 15, 2026 | 1 |
| Sep 14, 2026 | 1 |
| Sep 13, 2026 | 1 |
| Sep 12, 2026 | 1 |
| Sep 11, 2026 | 1 |
| Sep 10, 2026 | 1 |
| Sep 9, 2026 | 1 |
| Sep 8, 2026 | 1 |
| Sep 7, 2026 | 1 |
130 since Sep 7
| Date | Weekly downloads |
|---|---|
| Dec 6, 2026 | 13 |
| Dec 5, 2026 | 10 |
| Dec 4, 2026 | 11 |
| Dec 3, 2026 | 11 |
| Dec 2, 2026 | 15 |
| Dec 1, 2026 | 17 |
| Nov 30, 2026 | 18 |
| Nov 29, 2026 | 19 |
| Nov 28, 2026 | 27 |
| Nov 27, 2026 | 34 |
| Nov 26, 2026 | 213 |
| Nov 25, 2026 | 208 |
| Nov 24, 2026 | 205 |
| Nov 23, 2026 | 204 |
| Nov 22, 2026 | 201 |
| Nov 21, 2026 | 192 |
| Nov 20, 2026 | 183 |
| Nov 19, 2026 | 4 |
| Nov 18, 2026 | 4 |
| Nov 17, 2026 | 6 |
| Nov 16, 2026 | 6 |
| Nov 15, 2026 | 3 |
| Nov 14, 2026 | 4 |
| Nov 13, 2026 | 4 |
| Nov 12, 2026 | 4 |
| Nov 11, 2026 | 5 |
| Nov 10, 2026 | 4 |
| Nov 9, 2026 | 5 |
| Nov 8, 2026 | 8 |
| Nov 7, 2026 | 8 |
| Nov 6, 2026 | 8 |
| Nov 5, 2026 | 10 |
| Nov 4, 2026 | 9 |
| Nov 3, 2026 | 9 |
| Nov 2, 2026 | 9 |
| Nov 1, 2026 | 6 |
| Oct 31, 2026 | 5 |
| Oct 30, 2026 | 5 |
| Oct 29, 2026 | 2 |
| Oct 28, 2026 | 2 |
| Oct 27, 2026 | 1 |
| Oct 26, 2026 | 2 |
| Oct 25, 2026 | 2 |
| Oct 24, 2026 | 2 |
| Oct 23, 2026 | 2 |
| Oct 22, 2026 | 5 |
| Oct 21, 2026 | 5 |
| Oct 20, 2026 | 5 |
| Oct 19, 2026 | 4 |
| Oct 18, 2026 | 5 |
| Oct 17, 2026 | 5 |
| Oct 16, 2026 | 5 |
| Oct 15, 2026 | 4 |
| Oct 14, 2026 | 4 |
| Oct 13, 2026 | 4 |
| Oct 12, 2026 | 3 |
| Oct 11, 2026 | 4 |
| Oct 10, 2026 | 4 |
| Oct 9, 2026 | 4 |
| Oct 8, 2026 | 4 |
| Oct 7, 2026 | 4 |
| Oct 6, 2026 | 5 |
| Oct 5, 2026 | 6 |
| Oct 4, 2026 | 5 |
| Oct 3, 2026 | 6 |
| Oct 2, 2026 | 8 |
| Oct 1, 2026 | 6 |
| Sep 30, 2026 | 6 |
| Sep 29, 2026 | 5 |
| Sep 28, 2026 | 4 |
| Sep 27, 2026 | 4 |
| Sep 26, 2026 | 6 |
| Sep 25, 2026 | 4 |
| Sep 24, 2026 | 5 |
| Sep 23, 2026 | 5 |
| Sep 22, 2026 | 7 |
| Sep 21, 2026 | 8 |
| Sep 20, 2026 | 10 |
| Sep 19, 2026 | 7 |
| Sep 18, 2026 | 8 |
| Sep 17, 2026 | 9 |
| Sep 16, 2026 | 11 |
| Sep 15, 2026 | 10 |
| Sep 14, 2026 | 11 |
| Sep 13, 2026 | 8 |
| Sep 12, 2026 | 8 |
| Sep 11, 2026 | 9 |
| Sep 10, 2026 | 9 |
| Sep 9, 2026 | 9 |
| Sep 8, 2026 | 9 |
| Sep 7, 2026 | 13 |
Each point is npm's rolling 7-day download count.
Health Score
Composite score based on GitHub activity, stars, npm downloads, publish recency, dependency count, and package size.
Badge for your README
[](https://payloaddirectory.dev/plugins/1342020689-root)<a href="https://payloaddirectory.dev/plugins/1342020689-root"><img src="https://payloaddirectory.dev/badge/1342020689-root.svg" alt="Payload Directory"></a>README
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.
| Requirement | Version | Declared as |
|---|---|---|
payload | >=3.88 <4 | peer dependency |
@payloadcms/plugin-ecommerce | >=3.88 <4 | peer dependency |
react | >=19 <20 | optional peer dependency, only for the print buttons |
| Node | >=20 | engines |
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.
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.
Measured on 21 August 2026 against @payloadcms/plugin-ecommerce 3.88.0 and the npm registry.
| Question | Answer |
|---|---|
| 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 |
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.
| Test | Result |
|---|---|
Admin names slug as the source field | Code filled in on save, indexed and searchable |
| A source value the CMS transforms | Recorded value matches the stored value, not the submitted one |
| QR set to a URL template | Page scanned back as https://shop.example/p/walnut-table-99 |
| Print page | HTML, #000 and #fff only, prints on load |
| Several ids at once | One page, one label per product, no label split across pages |
| Value that is not a valid EAN-13 | Recorded with a plain explanation instead of a broken drawing |
| Print endpoint without a token | 403 |
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.
| Option | Default | Meaning |
|---|---|---|
collections | required | Collections that get a code, by slug |
disabled | false | Stops recording, leaves fields and settings in place |
fieldName | 'barcode' | Name of the field group holding the code |
settingsSlug | 'barcodes' | Slug of the settings global |
| Setting | Meaning |
|---|---|
| Source field | Field read for the code, for example sku. Nothing happens until this is set |
| Format | Code 128 for any printable ASCII, or EAN-13 for thirteen digit article numbers |
| QR code carries | The same value, or a URL built from it |
| URL template | Where {value} is replaced by the code, URL encoded |
| Print the value under the code | Adds the value in monospace under the bars |
| Where | Field | Notes |
|---|---|---|
| each named collection | barcode group | value (indexed), format, and error when the value cannot be drawn |
new global barcodes | source field, format, QR source, URL template, caption | Appears 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.
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 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.
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.
MIT. Copyright George Vasiliades, https://github.com/Poseidonas
ecommerce
Ecommerce utilities for Payload with idempotent Stripe confirmation, orders, carts and inventory handling
10019.0k/wk46.1kv3 v4
payload plugin scan
Read barcodes and QR codes by camera or USB scanner, and resolve scan links by signed-in user without allowing probing
76328/wk0v3
payload stock reservation
Validates variant stock and price at checkout and holds stock until payment settles or the hold expires
76152/wk1v3
payload plugin restock
Supplier lists, purchase orders and receiving drafted from stock levels, with copy-ready orders for suppliers without…
75232/wk0v3
payload plugin sample kits
Track sample kits from stock to keeper and back with custody trails, lot recalls and one-time activation secrets
74441/wk0v3
payload plugin kitting
Supply tracking, recipe-based kit building and ready-stock management for Payload with low-stock email alerts
74418/wk0v3