npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@trasherdk/svelte-qrcode

v0.2.3

Published

QR Code generator component for Svelte

Downloads

18

Readme

QR Code generator for Svelte

Note

This is a fork of https://github.com/bonosoft/sveltekit-qrcode

The original package is not maintained and does not support Svelte 5.

Install

Use your package manager to install the module directly from GitHub:

npm install @trasherdk/svelte-qrcode

Adding QR Codes to a svelte file in SvelteKit

Now you can start adding QR Codes to your pages.

<script lang="ts">
	import QRCode from "@trasherdk/svelte-qrcode"
</script>

<QRCode content="Test"></QRCode>

Alt text

Quick Response Codes

While conventional bar codes are capable of storing a maximum of approximately 20 digits, QR Code is capable of handling several dozen to several hundred times more information.

QR Code is capable of handling all types of data, such as numeric and alphabetic characters, Kanji, Kana, Hiragana, symbols, binary, and control codes. Up to 7,089 characters can be encoded in one symbol.

Content

Content is the text that needs to be send to the code reader. The text is normally an URL to a web site, or a code that is used by an application, for example in handling secrets in time based one time password applications.

<QRCode content="https://trasher.dk/"/>

Size, padding and responsive

You can set the size used for generation, the larger the size, the more information you are able to store in the QR code. The size is also used for the container in pixels. You can also specify the padding in module units, and recommended minimum is 4.

With the repsponsive settings enabled, the size settings will only be used in the code calculation, and the container will addapt and use all available space in it's parent element.

<QRCode size="50" content="https://trasher.dk/"/>

<QRCode padding="10" content="https://trasher.dk/"/>

<QRCode responsive='true' content="https://trasher.dk/"/>

Colours

With the colour settings, you can control both the front and background colour.

<QRCode color="#009900" content="https://trasher.dk/"/>

<QRCode color="#ffffff" bgcolor="#009900" content="https://trasher.dk/"/>

QR Code Color Examples

QR Code error correction

QR Code has error correction capability to restore data if the code is dirty or damaged. Four error correction levels are available for users to choose according to the operating environment. Raising this level improves error correction capability but also increases the amount of data QR Code size. To select error correction level, various factors such as the operating environment and QR Code size need to be considered. Level Q or H may be selected for factory environment where QR Code get dirty, whereas Level L may be selected for clean environment with the large amount of data. Typically, Level M (15%) is most frequently selected.

  • Level L Approx 7%
  • Level M Approx 15%
  • Level Q Approx 25%
  • Level H Approx 30%
<QRCode errorCorrection='L' content="https://trasher.dk/"/>

<QRCode errorCorrection='M' content="https://trasher.dk/"/>

<QRCode errorCorrection='Q' content="https://trasher.dk/"/>

<QRCode errorCorrection='H' content="https://trasher.dk/"/>

For use with Time based one time passwords (TOTP)

Sample URL for a John Doe user on the Acme app:

<QRCode content="otpauth://totp/ACME%20Co:[email protected]?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30"/>

QR Code TOTP Example