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

wifi-qr-code-generator

v1.1.1

Published

NPM module to generate a QR Code for WIFI ssid and password

Downloads

1,069

Readme

⭐️ Star us on GitHub — it helps!

wifi-qr-code-generator is an npm module to generate a QR Code to connect to your WiFi. Supports WiFi QR Codes in PNG, SVG, Terminal and UTF output formats. Works in both node server and browser.

Install

Using NPM:

$ npm install wifi-qr-code-generator

Using Yarn:

$ yarn add wifi-qr-code-generator

Usage

Basic API — Generating a PNG QR Code

const qrcode = require('wifi-qr-code-generator')
const pr = qrcode.generateWifiQRCode({
  ssid: 'Hello world',
  password: 'testpass',
  encryption: 'WPA',
  hiddenSSID: false,
  outputFormat: { type: 'image/png' }
})
pr.then((data) => console.log(data))

This prints the following output:

data:image/png;base64,iVBORw0KGgoAAA...

You can pass this data URL to an html img tag to generate the following QR code image:

API Explanation

Main API call is generateWifiQRCode which is shown in the example above. This method takes an object of the following format:

export interface Config {
  ssid: string
  password: string
  encryption: 'WPA' | 'WEP' | 'None'
  hiddenSSID: boolean
  outputFormat: OutputFormat
}

export interface OutputFormat {
  type: 'image/png' | 'utf8' | 'svg' | 'terminal'
}
  1. ssid: string representation of your wireless SSID (Wifi name). Max length possible for WiFi SSID is 32 characters for most routers. However this library doesn't impose any limitation on the length of SSID that can be passed in.
  2. password: string representation of your WiFi password
  3. encryption: Possible values here are WPA, WEP and None. If you are using WPA2, enter WPA. Please note that WEP protocol has multiple security vulnerabilities and you shouldn't be configuring your WiFi router to use WEP at all.
  4. hiddenSSID: should be true if your router is configured to NOT broadcast your SSID. Else false
  5. outputFormat: An object that has a single type field

Possible values of type are:

  1. "image/png": generateWifiQRCode will generates a data URL representing a PNG image
  2. "svg": generateWifiQRCode will generates an SVG image in string format
  3. utf8: generateWifiQRCode will generates a UTF8 representation of the QR code
  4. terminal: generateWifiQRCode will generates a string that can be pretty printed as QR code in the terminal

Generating a SVG QR Code

const qrcode = require('wifi-qr-code-generator')
const pr = qrcode.generateWifiQRCode({
  ssid: 'Hello world',
  password: 'testpass',
  encryption: 'WPA',
  hiddenSSID: false,
  outputFormat: { type: 'svg' }
})
pr.then((data) => console.log(data))

This prints the following output:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 41 41" shape-rendering="crispEdges">...

You can use the generated SVG directly in your HTML page to display the QR code.

Generating a UTF8 QR Code

const qrcode = require('wifi-qr-code-generator')
const pr = qrcode.generateWifiQRCode({
  ssid: 'Hello world',
  password: 'testpass',
  encryption: 'WPA',
  hiddenSSID: false,
  outputFormat: { type: 'utf8' }
})
pr.then((data) => console.log(data))

This prints the following output:


    █▀▀▀▀▀█ █▀█ █ ▀▄█▄ ▄█▄▄▄▀ █▀▀▀▀▀█
    █ ███ █ ▀▄▄▄▀  █ ▀▀▄  ▀██ █ ███ █
    █ ▀▀▀ █ ▀█ ▀  █▀ ▀█ ██ ██ █ ▀▀▀ █
    ▀▀▀▀▀▀▀ ▀▄█▄▀▄█ ▀▄█▄█▄█ █ ▀▀▀▀▀▀▀
    █  █▀█▀██▀▄ ▀▀ ▀▄▀▀██ ▀▄▄█  █▄██▀
    ▀▄█▀▀ ▀█▄ ▄██ █ ██▀ ▄▀ ███ ▀█ █
    ▄ ▄█▄▀▀█▄ █▀██▀ ██▀▄▀██▀██▀ ▀█▄█▀
     ██▄▀▀▀▀▀▄▄▀▄▀ ▄▀▄▀▄ ▀▀▀ ▀ ▀  ▄█
    ▄ █▄▀▄▀ ▄▄ ▄ ██▄█ ▀▀ ▄ ▄▄▄▄ ▄▄ ▄▄
    ▀█▀█▄█▀ ▄█▄▀ █▄  ▄▄██▄ ▄ ▀ ▀▄▄ ▀▀
    ▄ ▀ ▀ ▀▄▄▄▄  ▀█ ▄▄▄ █▀▄ ▄▀▀▀ ▀ █▄
    █ ▀███▀ ▄███▄█▀▀█▄█   █▄█▀█▄ ▄▀▀▀
    ▀▀    ▀ ▄▀▄▄▄███  ▀▀█ ███▀▀▀█▄▄ ▀
    █▀▀▀▀▀█ █▄█  ▀▄ █ ▀ ▀▀▀▀█ ▀ █ ▄█▄
    █ ███ █ █▄██▀ █▀ ▀▀▀█▀ █▀▀▀▀▀▄▄▀
    █ ▀▀▀ █   ▀█ █▄▄█▀█ ▀ ▀ ▀▄  █▀ █▀
    ▀▀▀▀▀▀▀ ▀  ▀▀    ▀▀ ▀▀▀ ▀▀   ▀▀▀

Generating a Terminal QR Code

const qrcode = require('wifi-qr-code-generator')
const pr = qrcode.generateWifiQRCode({
  ssid: 'Hello world',
  password: 'testpass',
  encryption: 'WPA',
  hiddenSSID: false,
  outputFormat: { type: 'terminal' }
})
pr.then((data) => console.log(data))

This generates the following QR code in your terminal:

Author

👤 Anoop Kunjuraman

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2020 Anoop Kunjuraman. This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator