Socket
Book a DemoInstallSign in
Socket

code-craft-studio

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-craft-studio

A comprehensive QR code and barcode scanning/generation library for React. Works with or without Capacitor. Supports 22+ QR data types and 14+ barcode formats (EAN, UPC, Code 128, etc.), with customizable designs, analytics, and React components. Provider

2.0.0
latest
Source
npmnpm
Version published
Weekly downloads
31
19.23%
Maintainers
1
Weekly downloads
ย 
Created
Source

Code Craft Studio

๐Ÿ“š Documentation

ResourceDescription
๐Ÿ“– API ReferenceComplete API documentation with all methods and options
๐Ÿš€ Quick Start GuideGet started in 5 minutes
๐Ÿ—๏ธ ArchitecturePlugin architecture and design decisions
โœจ FeaturesDetailed feature documentation
๐ŸŽฎ Interactive PlaygroundTry the API in your browser
๐Ÿ“ฑ Platform SetupiOS and Android configuration
๐ŸŽฅ Video TutorialsStep-by-step video guides
Code Craft Studio Logo

A comprehensive Capacitor plugin for QR code and barcode scanning/generation

npm version License: MIT Platform Support

๐Ÿš€ Features

Core Features

  • ๐Ÿ“ท QR Code Scanner: Native camera-based scanning with web fallback
  • ๐Ÿ”– Barcode Scanner: Scan 14+ barcode formats (EAN, UPC, Code 128, etc.)
  • ๐ŸŽจ QR Code Generator: Generate QR codes with full customization options
  • ๐Ÿ“Š Barcode Generator: Generate 1D and 2D barcodes with text overlay
  • ๐Ÿ“Š Analytics & History: Track scans, locations, and user engagement
  • ๐Ÿ’พ Multiple Export Formats: PNG, JPG, SVG, JSON, WebP (PDF, GIF, EPS, WMF coming soon)
  • โš›๏ธ React Components: Ready-to-use components for quick integration
  • ๐Ÿ“ฑ Cross-Platform: Works on Web, iOS, and Android
  • ๐Ÿ”Œ Plugin Architecture: Easy to extend and customize

22+ Supported QR Code Types & 14+ Barcode Formats

QR Code Types

  • ๐ŸŒ Web & Links: Website, PDF, Images Gallery, Video, Links List
  • ๐Ÿ“ฑ Social Media: Facebook, Instagram, WhatsApp, Social Media Hub
  • ๐Ÿ’ผ Business: vCard, Business Info, Menu, Coupon
  • ๐Ÿ”ง Utilities: WiFi, MP3, Apps, Text, Email, SMS, Phone, Location, Event
  • ๐ŸŽฏ Custom: Any custom data format

Barcode Formats

  • ๐Ÿ“Š 1D Barcodes:
    • EAN-13, EAN-8 (European Article Number)
    • UPC-A, UPC-E (Universal Product Code)
    • Code 128 (High-density alphanumeric)
    • Code 39, Code 93 (Alphanumeric with special characters)
    • ITF/ITF-14 (Interleaved 2 of 5)
    • Codabar (Numeric with special start/stop characters)
  • ๐Ÿ”ฒ 2D Barcodes:
    • QR Code (Quick Response)
    • Data Matrix (Compact 2D barcode)
    • PDF417 (Stacked linear barcode)
    • Aztec (Compact 2D barcode)

Advanced Options

  • ๐ŸŽจ Design Customization:
    • Custom colors (foreground/background)
    • Logo embedding
    • Frame styles
    • Margin control
    • Error correction levels (L, M, Q, H)
  • โš™๏ธ Generation Options:
    • QR version control (1-40)
    • Mask pattern selection (0-7)
    • Scale and size control
    • Kanji character support
  • ๐Ÿ“ธ Scanner Options:
    • Front/back camera switching
    • Torch/flashlight control
    • Custom scan regions
    • Video styling options
    • Scan delay configuration

๐Ÿ“ฆ Installation

For React Apps (No Capacitor Required)

npm install code-craft-studio
# or
yarn add code-craft-studio

That's it! The package works out of the box in any React app.

For Capacitor Apps

npm install code-craft-studio
npx code-craft-studio-setup

The setup script will:

  • Install optional Capacitor dependencies
  • Configure iOS and Android permissions
  • Sync Capacitor
  • Create example files

Manual Setup

# Install the package
npm install code-craft-studio

# Install Capacitor if not already installed
npm install @capacitor/core @capacitor/cli

# Add platforms
npx cap add ios
npx cap add android

# Sync
npx cap sync

iOS Configuration

Add to your Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>

Android Configuration

Add to your AndroidManifest.xml:

<uses-permission android:name="android.permission.CAMERA" />

๐ŸŽฏ Quick Start

Import Styles

Add to your main CSS file:

/* Import all Code Craft Studio styles */
@import 'code-craft-studio/src/styles/qrcode-studio.css';

Basic Usage

import { useCodeCraftStudio } from 'code-craft-studio';
import { QRType } from 'code-craft-studio';

// Works anywhere in your app - no providers needed!
function MyComponent() {
  const { 
    scanQRCode, 
    generateQRCode, 
    generateBarcode,
    isReady, 
    error 
  } = useCodeCraftStudio();

  const handleScan = async () => {
    try {
      const result = await scanQRCode();
      console.log('Scanned:', result.content);
    } catch (err) {
      console.error('Scan failed:', err);
    }
  };

  const handleGenerate = async () => {
    const result = await generateQRCode({
      type: QRType.WEBSITE,
      url: 'https://example.com'
    });
    console.log('Generated:', result.dataUrl);
  };

  if (!isReady) return <div>Loading...</div>;
  
  return (
    <div>
      <button onClick={handleScan}>Scan QR Code</button>
      <button onClick={handleGenerate}>Generate QR Code</button>
    </div>
  );
}

React Components

import {
  QRScanner,
  QRGenerator,
  QRStudio,
  BarcodeScanner,
} from 'code-craft-studio';

// Simple QR Scanner
function Scanner() {
  return (
    <QRScanner
      onScan={(result) => {
        console.log('Scanned:', result.content);
      }}
    />
  );
}

// Simple QR Generator
function Generator() {
  return (
    <QRGenerator
      type='website'
      data={{ url: 'https://example.com' }}
      size={300}
    />
  );
}

// Full Studio Component (QR + Barcode)
function Studio() {
  return (
    <QRStudio
      features={{
        scanner: true,
        generator: true,
        barcodeScanner: true,
        barcodeGenerator: true,
        history: true,
      }}
    />
  );
}

๐Ÿ”ง API Reference

Plugin API

Check Permissions

import { QRCodeStudio } from 'code-craft-studio';

const permissions = await QRCodeStudio.checkPermissions();
console.log(permissions.camera); // 'granted' | 'denied' | 'prompt'

Request Permissions

const permissions = await QRCodeStudio.requestPermissions();

Generate QR Code

const qrCode = await QRCodeStudio.generate({
  type: 'website',
  data: { url: 'https://example.com' },
  design: {
    colors: {
      dark: '#000000',
      light: '#FFFFFF',
    },
  },
  size: 300,
});

console.log(qrCode.dataUrl); // Base64 image
console.log(qrCode.svg); // SVG string

Start Scanning

// Add listener for scan results
const listener = await QRCodeStudio.addListener('scanResult', (result) => {
  console.log('Scanned:', result.content);
  console.log('Type:', result.type);
  console.log('Data:', result.parsedData);
});

// Start scanning
await QRCodeStudio.startScan({
  camera: 'back',
  showTorchButton: true,
});

// Stop scanning
await QRCodeStudio.stopScan();

// Remove listener
listener.remove();

Generate Barcode

const barcode = await QRCodeStudio.generateBarcode({
  format: 'EAN_13',
  data: '5901234123457',
  width: 300,
  height: 100,
  displayText: true,
});

console.log(barcode.dataUrl); // Base64 barcode image

Read Barcodes from Image

const result = await QRCodeStudio.readBarcodesFromImage({
  path: '/path/to/image.jpg',
  formats: ['EAN_13', 'CODE_128', 'QR_CODE'],
});

result.barcodes.forEach((barcode) => {
  console.log(`Format: ${barcode.format}, Data: ${barcode.rawValue}`);
});

๐ŸŽจ React Components

QRScanner Component

<QRScanner
  onScan={(result) => {
    console.log('Scanned:', result);
  }}
  onError={(error) => {
    console.error('Error:', error);
  }}
  options={{
    camera: 'back',
    scanDelay: 1000,
    showTorchButton: true,
    showFlipCameraButton: true,
  }}
  showOverlay={true}
  className='my-scanner'
/>

QRGenerator Component

<QRGenerator
  type='wifi'
  data={{
    ssid: 'MyNetwork',
    password: 'MyPassword',
    security: 'WPA2',
  }}
  design={{
    colors: {
      dark: '#2C3E50',
      light: '#FFFFFF',
    },
    logo: {
      src: 'https://example.com/logo.png',
      size: 60,
    },
    dotsStyle: 'rounded',
    cornersSquareStyle: 'extra-rounded',
  }}
  size={400}
  showDownload={true}
  showShare={true}
  onGenerate={(result) => {
    console.log('Generated:', result);
  }}
/>

BarcodeScanner Component

<BarcodeScanner
  formats={['EAN_13', 'UPC_A', 'CODE_128', 'CODE_39']}
  onScan={(result) => {
    console.log(`Scanned ${result.format}: ${result.rawValue}`);
    // Validate barcode if needed
    if (validateBarcodeData(result.format, result.rawValue)) {
      // Process valid barcode
    }
  }}
  onError={(error) => {
    console.error('Scan error:', error);
  }}
  continuous={false}
  torch={false}
  showOverlay={true}
/>

QRStudio Component

<QRStudio
  config={{
    allowedTypes: ['website', 'wifi', 'vcard', 'text'],
    defaultType: 'website',
    defaultDesign: {
      colors: {
        dark: '#000000',
        light: '#FFFFFF',
      },
    },
  }}
  theme={{
    primary: '#007AFF',
    secondary: '#5856D6',
    mode: 'light',
  }}
  features={{
    scanner: true,
    generator: true,
    landingPages: true,
    analytics: true,
    export: true,
    sharing: true,
    history: true,
    favorites: true,
    templates: true,
  }}
  onSave={(result) => {
    console.log('Saved:', result);
  }}
  onScan={(result) => {
    console.log('Scanned:', result);
  }}
/>

๐Ÿ“‹ Supported QR Code Types

TypeDescriptionRequired Data
websiteLink to any websiteurl, title?, description?
pdfShare PDF documentsurl, title?, description?
imagesMultiple images galleryimages[], title?, description?
videoVideo contenturl, title?, thumbnail?
wifiWiFi credentialsssid, password?, security
menuRestaurant menurestaurantName, categories[]
businessBusiness informationname, phone?, email?, website?
vcardDigital business cardfirstName?, lastName?, phone?, email?
mp3Audio filesurl, title?, artist?
appsApp store linksappStoreUrl?, playStoreUrl?
links_listMultiple linkstitle?, links[]
couponDiscount couponscode, description?, validUntil?
facebookFacebook pagepageUrl, pageName?
instagramInstagram profileprofileUrl, username?
social_mediaAll social linksfacebook?, instagram?, twitter?, etc.
whatsappWhatsApp chatphoneNumber, message?
textPlain texttext
emailEmail compositionto, subject?, body?
smsSMS messagephoneNumber, message?
phonePhone callphoneNumber
locationGeographic locationlatitude, longitude, address?
eventCalendar eventtitle, startDate, endDate?, location?

๐ŸŽจ Customization Options

Design Options

interface QRDesignOptions {
  colors?: {
    dark?: string; // Foreground color
    light?: string; // Background color
  };
  logo?: {
    src: string; // Logo URL
    size?: number; // Logo size
    margin?: number; // Logo margin
    borderRadius?: number;
  };
  frame?: {
    style: 'square' | 'rounded' | 'circle' | 'banner';
    text?: string;
    color?: string;
    textColor?: string;
  };
  dotsStyle?: 'square' | 'rounded' | 'dots' | 'classy' | 'extra-rounded';
  cornersSquareStyle?: 'square' | 'dot' | 'extra-rounded';
  cornersDotStyle?: 'square' | 'dot' | 'extra-rounded';
  backgroundImage?: string;
  imageSize?: number; // 0-1
  margin?: number; // Quiet zone
}

๐Ÿ“Š Analytics

Track QR code performance:

const analytics = await QRCodeStudio.getAnalytics({
  qrCodeId: 'qr_123',
  dateRange: {
    start: new Date('2024-01-01'),
    end: new Date(),
  },
  metrics: ['scans', 'unique_scans', 'locations', 'devices'],
});

console.log('Total scans:', analytics.totalScans);
console.log('Unique scans:', analytics.uniqueScans);
console.log('Top locations:', analytics.locations);
console.log('Device types:', analytics.devices);

๐Ÿ’พ Export Formats

  • PNG - Raster image format
  • JPG - Compressed image format
  • SVG - Vector format (scalable)
  • PDF - Document format
  • GIF - Animated format support
  • JSON - Raw QR data
  • WebP - Modern image format
  • EPS - Vector format for print
  • WMF - Windows metafile

๐Ÿ” Permissions

iOS

  • Camera permission for scanning
  • Photo library permission for saving (optional)

Android

  • Camera permission for scanning
  • Storage permission for saving (optional)

Web

  • Camera/getUserMedia permission for scanning

โš™๏ธ Advanced Configuration

Generation Options

All options are exposed to give you full control over QR code generation:

await QRCodeStudio.generate({
  type: 'website',
  data: { url: 'https://example.com' },

  // Basic options
  size: 300, // Image size in pixels
  errorCorrectionLevel: 'M', // L (7%), M (15%), Q (25%), H (30%)

  // Advanced options
  version: undefined, // QR version (1-40, auto if undefined)
  maskPattern: undefined, // Mask pattern (0-7, auto if undefined)
  margin: 4, // Quiet zone size
  scale: 4, // Scale factor (pixels per module)
  width: undefined, // Force specific width (overrides scale)
  toSJISFunc: undefined, // Kanji encoding function

  // Design options
  design: {
    colors: { dark: '#000000', light: '#FFFFFF' },
    logo: { src: 'logo.png', size: 60 },
    // ... other design options
  },
});

Scanner Options

Configure the scanner with extensive options:

await QRCodeStudio.startScan({
  // Camera options
  camera: 'back', // 'front' or 'back'
  showTorchButton: true, // Show flashlight toggle
  showFlipCameraButton: true, // Show camera switch button

  // Performance options
  scanDelay: 200, // Milliseconds between scans
  maxScansPerSecond: 5, // Alternative to scanDelay

  // Web-specific options
  videoStyle: {
    // Custom video element styling
    position: 'fixed',
    width: '100%',
    height: '100%',
    objectFit: 'cover',
  },
  highlightCodeOutline: true, // Highlight detected QR codes
  highlightScanRegion: true, // Highlight scan area
  calculateScanRegion: (video) => ({
    // Custom scan region
    x: video.videoWidth * 0.25,
    y: video.videoHeight * 0.25,
    width: video.videoWidth * 0.5,
    height: video.videoHeight * 0.5,
  }),

  // Format filtering
  formats: [BarcodeFormat.QR_CODE], // Scan only specific formats
});

๐Ÿงช Testing

Run the test suite:

npm test

๐Ÿ“Š Barcode Examples

Product Inventory Management

import { QRCodeStudio, validateBarcodeData } from 'code-craft-studio';

// Generate product barcode
async function createProductLabel(productId: string, sku: string) {
  // Generate EAN-13 barcode for product
  const barcode = await QRCodeStudio.generateBarcode({
    format: 'EAN_13',
    data: '5901234123457', // Your product EAN
    width: 300,
    height: 100,
    displayText: true,
    outputFormat: 'png',
  });

  // Also generate a QR code with detailed product info
  const qrCode = await QRCodeStudio.generate({
    type: 'text',
    data: { text: JSON.stringify({ id: productId, sku, warehouse: 'A1' }) },
    size: 200,
  });

  return { barcode, qrCode };
}

// Scan and validate product
async function scanProduct() {
  const listener = await QRCodeStudio.addListener('scanResult', (result) => {
    if (result.format === 'EAN_13') {
      if (validateBarcodeData('EAN_13', result.content)) {
        console.log('Valid product barcode:', result.content);
        // Look up product in database
      }
    }
  });

  await QRCodeStudio.startScan({
    formats: ['EAN_13', 'UPC_A', 'QR_CODE'],
  });
}

Ticket System with PDF417

import React from 'react';
import { QRCodeStudio } from 'code-craft-studio';

function TicketGenerator({ eventId, userId, seatNumber }) {
  const generateTicket = async () => {
    // Generate PDF417 barcode (common for tickets/boarding passes)
    const ticketBarcode = await QRCodeStudio.generateBarcode({
      format: 'PDF_417',
      data: JSON.stringify({
        event: eventId,
        user: userId,
        seat: seatNumber,
        timestamp: Date.now(),
      }),
      width: 400,
      height: 150,
    });

    return ticketBarcode;
  };

  return <button onClick={generateTicket}>Generate Ticket</button>;
}

Multi-Format Scanner Component

import React, { useState } from 'react';
import { BarcodeScanner, getBarcodeConstraints } from 'code-craft-studio';

function UniversalScanner() {
  const [lastScan, setLastScan] = useState(null);

  const handleScan = (result) => {
    const constraints = getBarcodeConstraints(result.format);

    setLastScan({
      format: result.format,
      data: result.rawValue,
      constraints: constraints.description,
    });

    // Handle different barcode types
    switch (result.format) {
      case 'QR_CODE':
        // Parse QR code data
        break;
      case 'EAN_13':
      case 'UPC_A':
        // Look up product
        break;
      case 'CODE_128':
        // Process inventory code
        break;
      case 'PDF_417':
        // Handle ticket/document
        break;
    }
  };

  return (
    <div>
      <BarcodeScanner
        formats={[
          'QR_CODE',
          'EAN_13',
          'EAN_8',
          'UPC_A',
          'UPC_E',
          'CODE_128',
          'CODE_39',
          'ITF',
          'PDF_417',
          'AZTEC',
        ]}
        onScan={handleScan}
        continuous={true}
      />

      {lastScan && (
        <div className='scan-result'>
          <h3>Last Scan</h3>
          <p>Format: {lastScan.format}</p>
          <p>Data: {lastScan.data}</p>
          <p>Type: {lastScan.constraints}</p>
        </div>
      )}
    </div>
  );
}

๐Ÿค Contributing

Contributions are welcome! Please read our Contributing Guide for details.

  • Fork the repository
  • Create your feature branch (git checkout -b feature/amazing-feature)
  • Commit your changes (git commit -m 'Add amazing feature')
  • Push to the branch (git push origin feature/amazing-feature)
  • Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Ahsan Mahmood

๐Ÿ™ Acknowledgments

๐Ÿ“ˆ Roadmap

  • Batch QR code generation
  • Custom QR code shapes
  • Animated QR codes
  • Advanced analytics dashboard
  • Cloud sync support
  • Bulk operations API
  • QR code templates marketplace

๐Ÿ’ก Support

Made with โค๏ธ by Ahsan Mahmood

Note

This package takes over and continues development from the original qrcode-studio package.

Keywords

capacitor

FAQs

Package last updated on 03 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.