Headless QR Code Generator In JavaScript

Category: Javascript | April 24, 2023
AuthorRich-Harris
Last UpdateApril 24, 2023
LicenseMIT
Tags
Views359 views
Headless QR Code Generator In JavaScript

A simple headless QR code generator that allows developers to programmatically create QR codes containing an n x n array of booleans, where `true` is a dark pixel.

How to use it:

1. Import the qs module.

import { qr } from 'headless-qr';

2. Generate a QR code from the data you provide.

const myQR = qr('https://www. cssscript.com');
// output [
  [
    true,
    true,
    true,
    true,
    true,
    true,
    true,
    false,
    true,
    false,
    true,
    false,
    false,
    true,
    false,
    false,
    false,
    false,
    true,
    true,
    true,
    true,
    true,
    true,
    true
  ],
  // ...
]

3. Specify the version and error correction level.

const myQR = qr('https://www. cssscript.com',{
      version: 40, // 1 - 40
      correction: 'Q' // L, M, Q or H
});

You Might Be Interested In:


Leave a Reply