csway-qr-generator

1.0.0 • Public • Published

Example:-

Javascript
import { generateQRCode } from "csway-qr-generator";

const search = "google.com";

generateQRCode(search, (error, qrCodeURL) => {
    if (error) {
        console.error('Error generating QR code:', error);
    } else {
        console.log('QR code URL:', qrCodeURL);
    }
});
ReactJs
import { useState } from "react";
import { generateQRCode } from "csway-qr-generator";

const QRCodeGenerator = () => {
  const [qrCodeData, setQRCodeData] = useState(null);
  const [searchText, setSearchText] = useState("");

  const handleSearch = () => {
    generateQRCode(searchText, (error, imageData) => {
      if (error) {
        console.error("Error generating QR code:", error);
      } else {
        setQRCodeData(imageData);
      }
    });
  };

  return (
    <div>
      <input
        type="text"
        value={searchText}
        onChange={(e) => setSearchText(e.target.value)}
        placeholder="Enter text for QR code"
      />
      <button onClick={handleSearch}>Generate QR Code</button>
      {qrCodeData && (
        <div>
          <img src={`data:image/png;base64,${qrCodeData}`} alt="QR Code" />
        </div>
      )}
    </div>
  );
};

export default QRCodeGenerator;

Package Sidebar

Install

npm i csway-qr-generator

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

3.65 kB

Total Files

4

Last publish

Collaborators

  • cscodeway