@marianmeres/svelte-qrcode
v1.3.0
Published
[QR-Code-generator](https://github.com/nayuki/QR-Code-generator) wrapped as a Svelte component.
Readme
@marianmeres/svelte-qrcode
QR-Code-generator wrapped as a Svelte component.
Installation
npm i @marianmeres/svelte-qrcodeUsage
<script>
import { QrCode } from '@marianmeres/svelte-qrcode';
</script>
<QrCode content="this will be qr encoded as svg string" />See playground for more parameters.
SVG as a string
The same encoder is available as pure, DOM-free functions — e.g. for a server endpoint
serving image/svg+xml, or a file download.
import { toQrSvg, toQrPath } from '@marianmeres/svelte-qrcode/qrcodegen';
// toQrSvg(content, ecl = 'medium', border = 4, lightColor = 'white', darkColor = 'black')
const svg = toQrSvg('https://example.com', 'quartile');
// raw geometry, to build your own markup
const { size, path } = toQrPath('https://example.com', 'quartile');toQrSvg returns a standalone SVG (with xmlns, viewBox, no width/height) which is also
valid inline in HTML. Both are re-exported from the package root too, but the
/qrcodegen subpath does not require a Svelte-aware bundler, so it also works in plain
Node or Deno.
