QR Code Reader / Scanner with JavaScript (Html5-QRCode.js)

  Рет қаралды 93,367

OpenJavaScript

OpenJavaScript

Күн бұрын

👉 Source code: openjavascript...
‍🎓 NEW: Earn a professional certificate in web development from Meta Inc. (course links in card below) 👇
⚡ Looking for high-performance, afforable web hosting? We use HostWithLove: bit.ly/3V2RM9Q ❤️
This tutorial shows you how to read / scan QR codes in JavaScript using the Html5-QRCode library.
#qrcode #reader #scanner #javascript #tutorial #javascript_tutorial #webdevelopment #nodejs
🔔 Subscribe for more tutorials just like this: / @openjavascript
⚡Web development professional certificates from Meta Inc.⚡
Front-End Developer Professional Certificate: imp.i384100.ne...
Back-End Developer Professional Certificate: imp.i384100.ne...
iOS Developer Professional Certificate: imp.i384100.ne...
Meta Android Developer Professional Certificate: imp.i384100.ne...
Meta Database Engineer Professional Certificate: imp.i384100.ne...
Website: openjavascript...
Twitter: / openjavascript

Пікірлер: 108
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Thanks for watching! 👉 Source code with live working example: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/ 👉 How to implement in React: kzbin.info/www/bejne/nJauqGh4htJ-f9U
@gircsi117
@gircsi117 Жыл бұрын
Hello, this module is very useful, but it doesn't allow activating the camera over HTTP, and our website doesn't have HTTPS. Could you help with this?
@adexitum
@adexitum Жыл бұрын
You are my saver. Only god knows how much time I spend trying to do this. Just made it in few minutes with you eventhough I used Angular
@mallikarjuntr3515
@mallikarjuntr3515 18 күн бұрын
Works man, two minutes job, that too with these modern frameworks and libraries ,it is made easy ,i would recommend everyone to try this.
@arthursallier4045
@arthursallier4045 Жыл бұрын
works, just copy the code example from the website if you want to be faster
@TeacherKaris
@TeacherKaris Жыл бұрын
Works! Thank you for the effort you put in sharing this knowledge and skill. Be blessed!
@sofiatachmatzidou175
@sofiatachmatzidou175 2 жыл бұрын
This is exactly what I needed. Thank you!!
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Glad to hear it - and you're weclome!
@yousifky
@yousifky 18 күн бұрын
Mannnn you are awesome thank you so much for this video you are the best bro
@Kleiner9Partizane
@Kleiner9Partizane 26 күн бұрын
This works perfectly! Thanks a lot !!!
@HiddenAway-j6s
@HiddenAway-j6s Ай бұрын
this will be really helpful thank youuu
@rashmikadeshan2710
@rashmikadeshan2710 5 ай бұрын
Thank you so much for sharing code.
@jerbparagas3924
@jerbparagas3924 11 ай бұрын
The scanner was great. Although it lack some styling customization
@jumpsiyx7106
@jumpsiyx7106 8 ай бұрын
omg dude, i fkn love you some much thank you for your help
@Cincinnatistorm
@Cincinnatistorm 9 ай бұрын
Great video 👍, I was looking for information about this type of tools and also RFID and NFC would be great for my project in the future now is just on paper because there are no many Devs interested in so many complexity of combined technologies
@tagyenblaisetechwi2069
@tagyenblaisetechwi2069 Жыл бұрын
Thanks , you are the best
@OpenJavaScript
@OpenJavaScript Жыл бұрын
Thanks, not the best I think, but appreciate the comment and glad you liked the video!
@chillywilly314
@chillywilly314 9 ай бұрын
This is exactly what I was looking for! Sucks that the barcode scanner API doesn't support iOS.
@AcePortgaz-s1o
@AcePortgaz-s1o Ай бұрын
great video
@skygrace4300
@skygrace4300 Жыл бұрын
Thanks for this useful tut'.
@dewdrops5497
@dewdrops5497 8 ай бұрын
how i can add input text to print qr code scan result as user id and a button for login
@piuniverse9306
@piuniverse9306 Жыл бұрын
Thank you you're a life saver, now may you please point me in the direction where I can learn how to customize the UI 🙏 🙏
@piuniverse9306
@piuniverse9306 Жыл бұрын
Oops I digress it ain't working 😢😢😢
@Lymphater
@Lymphater 5 ай бұрын
Nice. But I'd like to start scanning by click on my button. Without UI by library. Any idea?
@tolgaaymaz2017
@tolgaaymaz2017 2 жыл бұрын
so good :) thanks for share video
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Welcome :)
@lasithadulshan7357
@lasithadulshan7357 Жыл бұрын
Thank you !
@iamfyrus
@iamfyrus 5 ай бұрын
Live sample works but how to rescan another QR? Theres no scan button after the first scan
@Arief_programmer
@Arief_programmer Жыл бұрын
Successfully to get the result. but after that, camera still in use on the background. How to turn it off after get the result?
@pesgameryt1
@pesgameryt1 8 ай бұрын
And pls what is inside the qr scanner folder
@pesgameryt1
@pesgameryt1 8 ай бұрын
Sorry please I want to ask how did he get the qr scanner folder?
@rutchanontv4815
@rutchanontv4815 2 жыл бұрын
I've tried running the code on my machine. And it turns out that the camera works for a few seconds and then disappears. and up but the word that the camera is working please help me
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Have you tried running the source code?' There's the code to copy and a live working example here: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/ If that's still not working for you, let me know and I'll do my best to reply.
@rutchanontv4815
@rutchanontv4815 2 жыл бұрын
@@OpenJavaScript I have installed the source code runner and followed in the video. To test run the program on the test web that you have attached can be used. But when I run the program on my computer The camera works for a few seconds and then turns off. But in terms of importing images from the machine to read, it can be used. I use Visual Studio to run the program. please help me
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
​@@rutchanontv4815 If the live example in the blog post is working then that would rule out a hardware or browser-specific issue. A possibility is that it works in a HTTPS environment (like in the blog) but not locally via a HTTP server. You could try setting up VS Code LiveServer to run HTTPS as a test server.
@rutchanontv4815
@rutchanontv4815 2 жыл бұрын
@@OpenJavaScript Now I have uploaded the code to the server, it appears that it works normally, thank you.
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
@@rutchanontv4815 Great!
@invtrk1046
@invtrk1046 Жыл бұрын
When using this on Samsung smartphones, it defaults to using the wide-screen camera which results in bad performance scanning QR codes. Is there a way to fix this? Change the default camera to normal lense?
@drenyl6491
@drenyl6491 Жыл бұрын
Would this work using a real scanner? Like a honeywell xenon for scanning qr codes. Not using a phone camera
@OpenJavaScript
@OpenJavaScript Жыл бұрын
This library does also read QR codes from file so if you are getting the data from your scanner as a QR code in image format, you could feed it in that way. But often a QR code scanner will decode the QR code for you already and send you the data in text format. For this use case, I'd consider working in Node.js rather than in browser as it would be useful to run a server with access to the file system. If you do go down the Node.js route, you should check out the node-hid library because it's designed to allow you to connect to/get data from these kind of devices.
@colbr6733
@colbr6733 Жыл бұрын
@@OpenJavaScript Really appreciate you taking the time to respond to this, very useful answer.
@OpenJavaScript
@OpenJavaScript Жыл бұрын
@@colbr6733 You're welcome, good luck with the project!
@onlyInMirzapur
@onlyInMirzapur Жыл бұрын
Thankyou for the help but when the result pops up I want it to directly go to the website rather than showing the link of result? Is it possible??
@OpenJavaScript
@OpenJavaScript Жыл бұрын
Yes, for this you can call 'window.location.href = result' inside the success function.
@onlyInMirzapur
@onlyInMirzapur Жыл бұрын
@@OpenJavaScript thankyou for your help your work is amazing!
@OpenJavaScript
@OpenJavaScript Жыл бұрын
@@onlyInMirzapur You're welcome!
@diegomiranda5781
@diegomiranda5781 Жыл бұрын
Good afternoon! I'm trying to generate the data from the bill that was scanned, such as amount, expiration date, etc. For the user to make the payment. Can you tell me how to get this data using the number generated in the scanner?
@aodhan2011
@aodhan2011 Жыл бұрын
Possible to create a react tutorial using it?
@OpenJavaScript
@OpenJavaScript Жыл бұрын
Hi Andy, thanks for this suggestion, this tutorial has been pretty popular so I'll try to get around to making a React-specific version soon. UPDATE: Here's how you can implement it in React: kzbin.info/www/bejne/nJauqGh4htJ-f9U
@valofeeofficial9343
@valofeeofficial9343 Жыл бұрын
Thanks
@rahulmule1272
@rahulmule1272 Жыл бұрын
Your awesome 🎉🎉
@OpenJavaScript
@OpenJavaScript Жыл бұрын
Thanks! ❤
@junjungaming855
@junjungaming855 Жыл бұрын
can I use it with Laravel?
@PROTECHRAHUL
@PROTECHRAHUL 9 ай бұрын
Why there is a watermark, powered by scanapp
@portfedh
@portfedh Жыл бұрын
Would this work on a mobile phone?
@jayvinf2p782
@jayvinf2p782 Жыл бұрын
I tried to run this in my vs code but its not working the camera idk why but it can work tho in online compiler lol
@andreykachur3827
@andreykachur3827 2 жыл бұрын
good library, but it's a pity that you can't change styles and manage them more flexibly
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Certainly a nice advantage (and quite rare) that the library implements its own UI. Easy if you haven't done QR code reading before but that does raise issues of customization. If you haven't already, you might want to check out Html5-QRCode on GitHub: they have a pro mode implementation that is quite different from this tutorial. They suggest this alternative if you want to build your own UI.
@andreykachur3827
@andreykachur3827 2 жыл бұрын
@@OpenJavaScript Thanks, I'll read the description of this library in more detail and try to come up with something!
@HEiiZENBERG
@HEiiZENBERG 11 ай бұрын
Tried running on android web page, it is asking for me to choose a camera but unable to access it. How do I fix this? @OpenJavaScript
@ramussdev
@ramussdev Жыл бұрын
Does it works in an android device? I mean, I wanna make an app for android but web, like this, so I was thinking if it really works for android.
@metechantalya
@metechantalya Жыл бұрын
First of all thank you for your video. I found this source code and this is the first time I have understood how to do that. Thank you for that. But I have a question (need some help) I have an inventory management system. And I want to add products with qr codes. So I have decided to add a button for a pop up window (or can something else applied if you have an advice) to get the code from qr code and add it as a code to product. So later I can scan qr code and get the code and product with it. Any chance to help me with that?
@OpenJavaScript
@OpenJavaScript Жыл бұрын
It seems to me you have the first step down with this tutorial. For the sending of information on read QR codes, you'll want to send that using Fetch or similar and store that it in whatever storage/database solution you opt for (JSON data, SQL or maybe MongoDB). Then, it's just a case of retrieving that information by its storage ID from the database. For interactions with the database, you'll want to be doing that on the backend. You can use Node.js for that if you want to use JavaScript.
@amrithanshu3478
@amrithanshu3478 Жыл бұрын
Can we usei t in angular /typescript Code in typescript
@chan3ce450
@chan3ce450 Жыл бұрын
How can i set my barcode reader to scan only a few numbers? Example: -123456788 -and i wamt it to read only 23456?
@OpenJavaScript
@OpenJavaScript Жыл бұрын
I don't think it's possible to selectively scan some numbers but what you can do is to create a new value from the value you have scanned. For example, you could get the desired result in the example you gave using the substring method: function success(result) { const result = "123456788"; const resultSub = result.substring(1, 6); console.log(resultSub); // 23456 }
@chan3ce450
@chan3ce450 Жыл бұрын
@@OpenJavaScript Thank you for your answer sir :D
@OpenJavaScript
@OpenJavaScript Жыл бұрын
@@chan3ce450 you're welcome 😊
@user-ub7ku7gi9e
@user-ub7ku7gi9e Жыл бұрын
There's an error of uncaught cameraIdOrConfig
@NABILAHBINTISALLEHSTUDENT
@NABILAHBINTISALLEHSTUDENT Жыл бұрын
May I know how you create the folder (qr-scanner) at the beginning video which is at 1.54 minutes
@jerrymarchermoso8168
@jerrymarchermoso8168 2 жыл бұрын
can the default UI be changed to just a button to trigger the camera? specifically the back camera
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Yes, it's possible. It's more syntax than using the default UI but you can do it. For this, check out the documentation: github.com/mebjas/html5-qrcode
@jerrymarchermoso8168
@jerrymarchermoso8168 2 жыл бұрын
@@OpenJavaScript i tried it but it only works on android devices. Iphones always on front cam even if the cameras[1] name says back camera
@jerrymarchermoso8168
@jerrymarchermoso8168 Жыл бұрын
I've done it. lol its in the docs already hehe thank you!
@testaccount-fx7sq
@testaccount-fx7sq 2 жыл бұрын
I added the source code to my project of Angular Dart, and in the html view i can see the UI of the scanner, but when i load the project i cannot see the scanner UI . can you please suggest me something?
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
My guess would be you have some content that dynamically overwriting the scanner UI. If so, probably you need to integrate it into whatever component is overwriting it.
@piuniverse9306
@piuniverse9306 Жыл бұрын
its throwing a cameraIDOrConfig is required
@-RohanFukat
@-RohanFukat 2 жыл бұрын
Hi brother, I have got cameraIdOrConfig error, I don't know what's exactly the problem
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
There's a live working example here: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/ If it works for you, try copying the source code.
@-RohanFukat
@-RohanFukat 2 жыл бұрын
Thanks brother the error is solved. I am trying to run this code in . ejs file as but i am getting error that Refuse to execute html5-qrcode.min.js file because its MIME type is (text/html) is not executable, and strict mime type checking is enabled. Please tell me I got stuck on this error from 3-4 days.
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
@@-RohanFukat OK, glad to hear you found a solution!
@premkumars1281
@premkumars1281 2 жыл бұрын
QR code parse error, error = D: No MultiFormat Readers were able to detect the code. How to resolve this?
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
I'm not sure but you could try removing the CSS setting height and width for the video. Sometimes this can cause some interference.
@Tanmaygaming0406
@Tanmaygaming0406 Жыл бұрын
@@OpenJavaScript Not sure, it didn't resolved too.
@thanakornnithipatarpa8790
@thanakornnithipatarpa8790 Жыл бұрын
I found this error too
@darimoprom2580
@darimoprom2580 7 ай бұрын
Jesus Man you save my life
@garimasingh3073
@garimasingh3073 Жыл бұрын
throw "cameraIdOrConfig is required"; yeh error aa rha js mai
@OpenJavaScript
@OpenJavaScript Жыл бұрын
This error can occur when you try to run the QR reader from the file system (not on a server). See if the live example in the blog post works for you: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/ If so, this is likely the issue. To fix when testing, try running it on a server you are running locally (if you are using VS Code, the Live Server extension will do this for you).
@masyas860
@masyas860 Жыл бұрын
can this work for android camera? it shows NotAllowedError: Permission Denied even if it didn't ask for permissions
@OpenJavaScript
@OpenJavaScript Жыл бұрын
This is usually due to general browser settings blocking access to the camera or blocking access for a specific domain. Then it won't ask and immediately reject permission. I did just test a live example in Android (openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/) and confirm that it is at least working here. When I blocked the domain I got the same error you did. Hope this helps to solve your problem.
@ibrahimelalami6524
@ibrahimelalami6524 Жыл бұрын
Working for code barre ??
@OpenJavaScript
@OpenJavaScript Жыл бұрын
Yes, it can also read a bar code if you feed one into it.
@Rabatata_Extreme
@Rabatata_Extreme 2 жыл бұрын
Im actually getting an error... "Qr code parse error, error = D: No MultiFormat Readers were able to detect the code.
@Rabatata_Extreme
@Rabatata_Extreme 2 жыл бұрын
I mean it works... But i get a lot off spam in console while i dont read. Is that supposed to happen?
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
@@Rabatata_Extreme Yes, that's actually normal. The error function is fired every time it can't read the QR code (quite a lot!). From the official documentation: function onScanFailure(error) { // handle scan failure, usually better to ignore and keep scanning. // for example: console.warn(`Code scan error = ${error}`); }
@fredwanderley
@fredwanderley 2 жыл бұрын
Tks !!
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Welcome!
@shrikanttiwari1297
@shrikanttiwari1297 Жыл бұрын
not working at all , not allowederror:permission denied
@pablomansilla2497
@pablomansilla2497 2 жыл бұрын
I tried to replicate the qr scanner, but mine's not working ;-;
@pablomansilla2497
@pablomansilla2497 2 жыл бұрын
im using html only btw
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
​@@pablomansilla2497 No JavaScript? Because you'll need to use at least some to get this library working. If you haven't already, you may want to copy the live working example I posted on the blog post for this video here: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/
@pablomansilla2497
@pablomansilla2497 2 жыл бұрын
@@OpenJavaScript obviously I'm using js xD, but even copying and pasting the code doesn't work for me ;-;. I also tried different versions of the library but still nothing
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
@@pablomansilla2497 Does the live example on the blog work? Are you getting an error?
@bascbrims
@bascbrims 2 жыл бұрын
source code please
@OpenJavaScript
@OpenJavaScript 2 жыл бұрын
Now here with live working example: openjavascript.info/2022/12/10/qr-code-scanner-with-html5-qrcode-js/
@spreadItWide
@spreadItWide 6 ай бұрын
The only thing that doesn't work in your app is the corona test 😂😂
@Arush-qz4dn
@Arush-qz4dn Жыл бұрын
Not working 🥲
Subtle, yet Beautiful Scroll Animations
5:04
Beyond Fireship
Рет қаралды 1,8 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
How To Create QR Codes With JavaScript
8:18
dcode
Рет қаралды 4,2 М.
HTML QrCode Scanner with Javascript
6:25
Sri Edy Nurcahyo
Рет қаралды 24 М.
Making a QR Code with NPM Plugin in #Weweb_io
17:54
State Change
Рет қаралды 1,3 М.
Build Real Time Face Detection With JavaScript
12:41
Web Dev Simplified
Рет қаралды 1,4 МЛН
I built a QR code with my bare hands to see how it works
35:13
Veritasium
Рет қаралды 7 МЛН
HTML Tutorial for Beginners: HTML Crash Course
1:09:34
Programming with Mosh
Рет қаралды 9 МЛН
Create A Simple JavaScript App to Generate QR Codes
37:13
Traversy Media
Рет қаралды 108 М.
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 41 МЛН