Skip to main content

Overview

Atomix QRGen provides comprehensive TypeScript types for all supported QR code formats. These types ensure type safety when working with QR data throughout the application.

QrTypeKey

Enum defining the supported QR code types.
enum QrTypeKey {
  PlainText = "PT",
  Url = "UL",
  Wifi = "WF",
  VCard = "VC",
  Payment = "PB",
  Event = "EV",
}

Values

PlainText
string
default:"PT"
Plain text QR code type identifier
Url
string
default:"UL"
URL QR code type identifier
Wifi
string
default:"WF"
WiFi network QR code type identifier
VCard
string
default:"VC"
vCard contact QR code type identifier
Payment
string
default:"PB"
Payment QR code type identifier
Event
string
default:"EV"
Calendar event QR code type identifier

Data Interfaces

TextQrData

Interface for plain text QR codes.
interface TextQrData {
  text: string;
}
text
string
required
The text content to encode in the QR code

UrlQrData

Interface for URL QR codes.
interface UrlQrData {
  url: string;
}
url
string
required
The URL to encode. Protocol prefix (http:// or https://) is optional and will be added automatically

WifiQrData

Interface for WiFi network QR codes.
interface WifiQrData {
  ssid: string;
  password: string;
  security: "WPA" | "WEP" | "nopass";
}
ssid
string
required
Network SSID (name). Maximum 32 characters
password
string
required
Network password. Required for WPA and WEP security types
security
'WPA' | 'WEP' | 'nopass'
required
Network security type. Use “nopass” for open networks

VCardQrData

Interface for vCard contact QR codes.
interface VCardQrData {
  firstName: string;
  lastName: string;
  phone: string;
  mobile: string;
  email: string;
  organization: string;
  title: string;
  website: string;
  address: string;
  note: string;
}
firstName
string
required
Contact’s first name
lastName
string
required
Contact’s last name
phone
string
Landline phone number
mobile
string
Mobile phone number
email
string
Email address
organization
string
Organization or company name
title
string
Job title or position
website
string
Website URL
address
string
Physical address
note
string
Additional notes

PaymentQrData

Interface for payment QR codes.
interface PaymentQrData {
  method: string;
  name: string;
  account: string;
  bank: string;
  amount: number;
  reference: string;
}
method
string
required
Payment method. Use “crypto” for cryptocurrency payments
name
string
required
Recipient’s name
account
string
required
Account number or cryptocurrency address
bank
string
required
Bank name or payment platform
amount
number
required
Payment amount. Must be greater than 0
reference
string
Payment reference or memo

EventQrData

Interface for calendar event QR codes.
interface EventQrData {
  title: string;
  description: string;
  location: string;
  start: string;
  end: string;
}
title
string
required
Event title
description
string
Event description
location
string
required
Event location
start
string
required
Event start date and time (ISO format)
end
string
required
Event end date and time (ISO format). Must be after start time

Union Types

QrDataUnion

Union type of all QR data interfaces.
type QrDataUnion =
  | TextQrData
  | UrlQrData
  | WifiQrData
  | VCardQrData
  | PaymentQrData
  | EventQrData;

QrTypeDataMap

Mapped type connecting QR type keys to their corresponding data interfaces.
type QrTypeDataMap = {
  [QrTypeKey.PlainText]: TextQrData;
  [QrTypeKey.Url]: UrlQrData;
  [QrTypeKey.Wifi]: WifiQrData;
  [QrTypeKey.VCard]: VCardQrData;
  [QrTypeKey.Payment]: PaymentQrData;
  [QrTypeKey.Event]: EventQrData;
};
This type ensures type safety when working with QR data based on the selected QR type key.

Usage Example

import { QrTypeKey, type WifiQrData, type QrDataUnion } from './types/qr';

// Strongly typed WiFi QR data
const wifiData: WifiQrData = {
  ssid: "MyNetwork",
  password: "securepassword123",
  security: "WPA"
};

// Using the union type
const qrData: QrDataUnion = wifiData;

// Type-safe key usage
const qrType = QrTypeKey.Wifi; // "WF"

Build docs developers (and LLMs) love