Skip to content

@qrcodesdk/core

@qrcodesdk/core generates QR matrices, SVG strings, and terminal text without browser or Node.js APIs. Custom renderers can turn its matrices into other formats.

Terminal window
npm install @qrcodesdk/core
import {QRCodeSVGRenderer, qrcode} from '@qrcodesdk/core';
const svg = qrcode('https://qrcodesdk.dev').render(QRCodeSVGRenderer());

The result is an SVG string. See the SVG renderer reference for its options and constraints.

Capability API Return type
Generate a QR matrix qrcode(payload).matrix() QRCodeMatrix
Render scalable vector output QRCodeSVGRenderer SVG string
Render terminal output QRCodeTextRenderer text string

See Builder and matrix for accepted payloads, matrix options, builder methods, and matrix output.

Import shape and pattern factories from @qrcodesdk/core/style:

import {QRCodeSVGRenderer, qrcode} from '@qrcodesdk/core';
import {circle, finder, rounded} from '@qrcodesdk/core/style';
const svg = qrcode('https://qrcodesdk.dev').render(
QRCodeSVGRenderer({
style: {
moduleSize: 8,
foreground: '#0f172a',
modules: rounded(),
finder: finder({ring: rounded({radius: 1}), center: circle(), color: '#e11d48'}),
},
}),
);

See Customize appearance for style options and custom shapes.

Typed helpers serialize common application values before generation. See Payload helpers for email, phone, SMS, geographic, and Wi-Fi payloads.

@qrcodesdk/core supports any JavaScript runtime providing native ESM, ES2020 support, and a global TextEncoder. It has no Node.js, DOM, filesystem, or framework dependency.

TypeScript projects should use moduleResolution: 'bundler', 'node16', or 'nodenext' to resolve the package’s ESM entry points and subpaths.

Runtime Support policy
Node.js All maintained LTS lines
Deno Current stable major
Bun Current stable release
Browsers Current evergreen browser families
Other runtimes and edge workers Native ESM, ES2020, and a global TextEncoder required

For runtime-specific output, add the package for your runtime or framework:

Package Use it for Return value
@qrcodesdk/browser Canvas element, PNG, WebP, GIF, and JPEG Image elements, browser downloads HTMLCanvasElement, HTMLImageElement, void
@qrcodesdk/node PNG, WebP, GIF, and JPEG bytes Buffer
@qrcodesdk/cli Command line generation from terminals and scripts Terminal text, SVG, PNG, WebP, GIF, and JPEG files
@qrcodesdk/react React SVG, PNG, WebP, GIF, JPEG, and Canvas components React element
@qrcodesdk/vue Vue SVG, PNG, WebP, GIF, JPEG, and Canvas components Vue component
@qrcodesdk/svelte Svelte SVG, PNG, WebP, GIF, JPEG, and Canvas components Svelte component
@qrcodesdk/angular Angular SVG, PNG, WebP, GIF, JPEG, and Canvas components Angular component

Compare every built-in output in Renderer outputs.

The root exports the builder, renderers, errors, and shared types. For direct ESM imports without a bundler, use @qrcodesdk/core/matrix, @qrcodesdk/core/svg, @qrcodesdk/core/text, or @qrcodesdk/core/error to avoid loading unrelated renderers. Bundled applications can use root imports with tree shaking.

Import shape and pattern factories and custom path types from @qrcodesdk/core/style. Matrix types and role names belong to @qrcodesdk/core/matrix; payload serializers belong to @qrcodesdk/core/payload. See Custom renderers for matrix-based custom renderer examples.

import {
type QRCodeDataImageURL,
QRCodeError,
type QRCodeErrorCode,
type QRCodeErrorOptions,
type QRCodeSVGAccessibilityOptions,
type QRCodeSVGCenterImage,
type QRCodeSVGOptions,
QRCodeSVGRenderer,
type QRCodeSVGRendererOptions,
type QRCodeTextANSIBackgroundOptions,
type QRCodeTextANSIOptions,
QRCodeTextRenderer,
type QRCodeTextRendererOptions,
type QRCodeTextStyle,
QR_CODE_ERROR_CODES,
svgCenterImage,
} from '@qrcodesdk/core';
import {
QRCodeBuilder,
type QRCodeEncodingMode,
type QRCodeErrorCorrectionLevel,
type QRCodeMask,
type QRCodeMatrix,
type QRCodeMatrixOptions,
type QRCodeMode,
type QRCodeModuleRole,
type QRCodePayload,
type QRCodeRenderer,
type QRCodeSegment,
type QRCodeSegmenter,
type QRCodeSegmenterOptions,
type QRCodeVersion,
QR_CODE_MODULE_ROLES,
qrcode,
} from '@qrcodesdk/core/matrix';
import {
type QRCodeEmailPayload,
type QRCodeGeoPayload,
type QRCodePhonePayload,
type QRCodeSMSPayload,
type QRCodeWiFiEncryption,
type QRCodeWiFiPayload,
emailPayload,
geoPayload,
phonePayload,
smsPayload,
wifiPayload,
} from '@qrcodesdk/core/payload';
import {
type QRCodeAlignmentCenterShape,
type QRCodeAlignmentOptions,
type QRCodeAlignmentRingShape,
type QRCodeAlignmentStyle,
type QRCodeCenterImageLayout,
type QRCodeCircleShapeOptions,
type QRCodeColor,
type QRCodeFinderCenterShape,
type QRCodeFinderOptions,
type QRCodeFinderRingShape,
type QRCodeFinderStyle,
type QRCodeModulePattern,
type QRCodeModuleShape,
type QRCodeRoundedShapeOptions,
type QRCodeShape,
type QRCodeShapePath,
type QRCodeShapePiece,
type QRCodeVisualStyle,
alignment,
circle,
customShape,
diagonal,
finder,
rounded,
} from '@qrcodesdk/core/style';

Output is deterministic for one installed implementation, but matrix modules, SVG markup, and PNG, WebP, GIF, and JPEG bytes may change between QRCodeSDK releases. Pin exact package versions and keep fixtures when exact artifacts matter. See the version and output policy.

Auto mode detects one encoding mode by default. Import the optimizer separately to combine modes when that reduces the symbol size:

import {qrcode} from '@qrcodesdk/core';
import {automaticSegmenter} from '@qrcodesdk/core/segmenter';
qrcode('ABCD12345678901234567890abcd').mode('auto').segmenter(automaticSegmenter).matrix();

mode: 'auto' works with or without the segmenter. Concrete modes bypass it. See Builder and matrix for the callback contract and version-selection behavior.

@qrcodesdk/core

Version
v0.0.5
Downloads
681/mo
Install size
385.8 kB
Bundled size
7.9 kB
Works with
Works with Google ChromeWorks with FirefoxWorks with Safari
Works with Node.jsWorks with BunWorks with Deno

Support QRCodeSDK

If you find QRCodeSDK useful, please consider sponsoring the project!