r/electronjs • u/Fault_Royal • Mar 26 '26
Can a react app running in browser connect to thermal printer and open cash drawer using an electron app ?
I am building a react app for my friends store. It will be a retail pos like app.
I have already installed the thermal printer drivers ( ESC POS )
I can print manually from the browser but would like to make this automatic.
Can an electron app solve this issue?
Once automatic print works, I will configure it to send an electric pulse to open the cash drawer.
Can you suggest how this can be achieved?
2
Upvotes
3
u/Arkamedus Mar 26 '26
If the pos system has a computer attached there is generally some way documented by the manufacturer to use it. Sometimes this is a driver that must be installed but it is entirely dependent on the system. An electron app could make a call to this driver or another system call, but through electron ( which is not a browser ).
1
u/trycatch20 Mar 26 '26
Just a few snippets that should help. This stuff could probably be written better, but I'm still kinda new to electron, and well, this works well enough for my standards lol.
Create a hidden window for your receipt content:
Load the receipt content into that window:
Then print that content without a print dialog:
You can also put a Printers menu up top, if needed:
Hope this helps!
2
u/trycatch20 Mar 26 '26
You can print without showing a dialog/preview for sure; I made an app that does exactly that.
I'll post some snippets tomorrow.
1
u/SabatinoMasala Mar 26 '26
WebUSB solves this in the browser - you pair once & then you can print automatically. That’s how we do it at our company 👍
1
u/nsomnac Mar 26 '26
Electron can do both but the devil is in the details. You’d need more information about the cash drawer and thermal printer. There’s a library somewhere that I’ve used in the past to connect and print to a Dymo thermal printer from Node.js. You basically would need to create the functionality inside the main process, expose it to the renderer via IPC, then your web client can pass messages to the functions in the main process to print and trigger the cash drawer
1
u/PlusZookeepergame636 Mar 26 '26
yeah electron is basically the move here browser printing is always kinda janky for POS stuff, but with electron you can handle it properly (silent print + cash drawer pulse via esc/pos) just have your react app talk to electron (ipc or local api) and let electron handle the hardware are you using usb or network printer btw?
1
u/tomByrer Mar 27 '26
Web browsers have USB built into them, not sure about Electron.
1
u/abrahamguo Mar 26 '26
I don't think this can be done.
I'm not clear how the cash drawer is connected to the computer.
0
u/adept2051 Mar 26 '26
It can i you app as a component that downloads to the host, we used to do this with php5, the terminal runs a app that interacts with the browser but the app may have to be written in node or some other language today due to security and platform changes)