DEV Community

Pavel Kříž
Pavel Kříž

Posted on

4 3

PWA (mobile) app: Read configuration from QR code

This is my 2nd write up on dev.to site. This article shows proof-of-concept, fully working with Chrome on Android.

A small background

I am a fan of mobile apps, I have developed a few apps (HTML + CSS + JS) using Cordova in past. One day i found out that there are PWA applications and since then I have loved them. Now I write apps as PWA/SPA ones using Quasar framework.

Apps need settings

As I have developed apps, some of them used configuration, often using dialog box. So, user fill/change configuration via standard dialog.

Sometimes I need special configuration of app (not related to user). Instead of fill API keys (or similar strange text string) manually we can use QR code. It assumes that we use QR library to mane reading QR code. And the app grows...

But wait! Many of us have QR reader app already installed on mobile phone. So, can we use it as an external source via clipboard? Yes, we can. :-)

Just scan QR code using external QR reader app, it stores text/config/whatever to clipboard.

Paste from clipboard

Nothing new, nothing fancy, yawn. One button and a function called on click event. And that's it!

vanilla JS code:

async function paste(input) {
  const text = await navigator.clipboard.readText();
  input.value = text;
}
Enter fullscreen mode Exit fullscreen mode

VueJS code:

pasteFromClipboard: async function(){
  const text = await navigator.clipboard.readText();
  this.textFromClipboard = text;
}
Enter fullscreen mode Exit fullscreen mode

Hope this help you :-)

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Retry later