Developer Documentation

Privacy-First Philosophy

When implementing QR code generation in your applications, we encourage you to follow our privacy-first approach: generate QR codes client-side whenever possible to protect user data.

Why Client-Side Generation?

  • Privacy: User data never leaves their device
  • Security: No man-in-the-middle attacks possible
  • Performance: No network latency for generation
  • Scalability: No server costs for QR generation
  • Compliance: Automatic GDPR/CCPA compliance

Recommended Libraries

JavaScript/TypeScript

  • qrcode: Comprehensive QR code generator (npm install qrcode)
  • qrcode.react: React component for QR codes (npm install qrcode.react)
  • qr.js: Lightweight alternative (npm install qr.js)

Python

  • qrcode: Pure Python QR generator (pip install qrcode[pil])
  • python-qrcode: Feature-rich alternative

Other Languages

  • Go: github.com/skip2/go-qrcode
  • Ruby: rqrcode gem
  • PHP: chillerlan/php-qrcode
  • Java: ZXing library

Code Examples

// Client-side QR generation using qrcode.js
import QRCode from 'qrcode';

// Generate QR code as data URL
const generateQR = async (text) => {
  try {
    const url = await QRCode.toDataURL(text, {
      color: {
        dark: '#000000',
        light: '#FFFFFF'
      },
      errorCorrectionLevel: 'H',
      width: 256
    });
    return url;
  } catch (err) {
    console.error(err);
  }
};

// Generate and display
const qrDataUrl = await generateQR('https://example.com');
document.getElementById('qr').src = qrDataUrl;

QR Code Best Practices

Error Correction Levels

  • L (Low ~7%): Use for clean environments, maximum data capacity
  • M (Medium ~15%): Default for most applications
  • Q (Quartile ~25%): Good for industrial/outdoor use
  • H (High ~30%): Best for logos/icons or harsh conditions

Size Guidelines

  • Minimum size: 2cm × 2cm for close-range scanning
  • Add 4 module quiet zone (white border) around QR code
  • For print: Use vector format (SVG) when possible
  • For digital: 256×256px minimum, 512×512px recommended

Color Contrast

  • Maintain high contrast (ideally black on white)
  • Dark colors for foreground, light for background
  • Test custom colors with various QR readers
  • Avoid inverted colors (light on dark) when possible

Data Formats

URL

https://example.com

WiFi

WIFI:T:WPA;S:NetworkName;P:Password;;

Email

mailto:[email protected]?subject=Hello&body=Message

SMS

SMSTO:+1234567890:Your message here

Phone

tel:+1234567890

Geographic Location

geo:40.7128,-74.0060

Calendar Event

BEGIN:VEVENT
SUMMARY:Meeting
DTSTART:20250820T100000Z
DTEND:20250820T110000Z
END:VEVENT

Testing Your Implementation

  • Test with multiple QR code reader apps
  • Verify on both iOS and Android devices
  • Check scanning at various distances
  • Test with different lighting conditions
  • Validate special characters and Unicode support
  • Ensure proper encoding for your data type

Security Considerations

  • Input Validation: Always validate and sanitize user input
  • URL Validation: Check for malicious URLs before encoding
  • Size Limits: Implement reasonable data size limits
  • Rate Limiting: Prevent abuse in server-side implementations
  • HTTPS Only: Always use HTTPS for web implementations

Contributing

We welcome contributions to the privacy-focused QR code generation ecosystem. If you've built something cool or have improvements to suggest:

  • Share your privacy-focused implementations
  • Report bugs or suggest features
  • Contribute to open-source QR libraries
  • Help translate documentation

Support

Need help with your implementation? Resources available:

  • Check our FAQ for common questions
  • Visit Quantum Peg for professional support
  • Review library-specific documentation
  • Join developer communities for your chosen library

License & Usage

The code examples and documentation on this page are provided under the MIT License. You're free to use, modify, and distribute them in your projects. We only ask that you respect user privacy in your implementations.