Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@castlenine/sveltekit-qrcode

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@castlenine/sveltekit-qrcode

QR Code generator component for SvelteKit

  • 1.0.3
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

QR Code generator for SvelteKit

Install

Use your package manager to install the module:

npm install @castlenine/sveltekit-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 "@castlenine/sveltekit-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://duxreserve.com"/>

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 isResponsive settings enabled, the size settings will only be used in the code calculation, and the container will adapt and use all available space in it's parent element.

<QRCode size={50} content="https://duxreserve.com"/>

<QRCode padding={10} content="https://duxreserve.com"/>

<QRCode isResponsive content="https://duxreserve.com"/>

Colours

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

<QRCode color="#009900" content="https://duxreserve.com"/>

<QRCode color="#ffffff" backgroundColor="#009900" content="https://duxreserve.com"/>

Alt text

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% (default value)
  • Level M Approx 15%
  • Level Q Approx 25%
  • Level H Approx 30%
<QRCode errorCorrection='L' content="https://duxreserve.com"/>

<QRCode errorCorrection='M' content="https://duxreserve.com"/>

<QRCode errorCorrection='Q' content="https://duxreserve.com"/>

<QRCode errorCorrection='H' content="https://duxreserve.com"/>

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:john.doe@email.com?secret=HXDMVJECJJWSRB3HWIZR4IFUGFTMXBOZ&issuer=ACME%20Co&algorithm=SHA1&digits=6&period=30"/>

Alt text

Acknowledgement

Thank you Bo Nørgaard @bonosoft for the original code

Keywords

FAQs

Package last updated on 04 Sep 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc