Local TCP Bridge is a Native Messaging host that lets web apps stream raw bytes straight to local hardware, like ESC/POS thermal printers on your network or plugged in by USB, over a secure, millisecond-latency binary protocol. No cloud hop, no print server.
Browsers deliberately can't open raw TCP sockets, and can't reach most USB printers either. Local TCP brings that capability back, safely, by pairing a lightweight Chrome extension with a tiny Node.js native host that does the hardware work on your machine.
Native installers for macOS .pkg, Windows .exe & Linux .run. No terminal needed. The installer registers everything and auto-installs Node.js if it's missing.
Chrome's Native Messaging sandbox plus a configurable origin allowlist, so you can lock the bridge down to only your own web apps, straight from the popup.
Streams raw ESC/POS bytes with millisecond precision, over the network or USB. Concurrent jobs are correlated by reqId and serialized per printer, so byte streams never interleave.
Works with Flutter Web, React, Vue, Angular or plain JS. The content script bridges every page, with no SDK and no globals to load.
Runs through the system node binary. That is exactly what keeps it working under macOS 15/26 Local Network Privacy, where an unsigned standalone binary gets silently blocked from the LAN.
Under MV3 the service worker can sleep. PRINT/SEND re-dial the socket automatically, so printing keeps working with no manual reconnect.
Each request is tagged, gated, and correlated on its way from the page to the printer. The response then travels the same wire back.
Sends a window.postMessage tagged with a unique messageId to the injected content script.
Forwards the message to the extension background, then posts the reply back scoped to the page's own origin, never a * wildcard.
Checks the origin allowlist, then relays the request (tagged with a reqId) to the Native Messaging host over a single persistent port.
Opens a raw TCP socket to your hardware on port 9100, or writes straight to a USB printer, then echoes the reqId back so concurrent jobs never cross wires.
Use plain JavaScript on any web framework, or the official Flutter package for one API across web, mobile & desktop. Always check availability first with CHECK_BRIDGE.
A tiny promise-based wrapper. No imports and no globals: the content script relays window.postMessage to the host.
export class LocalTcp {
constructor({ timeoutMs = 30000 } = {}) {
this._pending = new Map();
window.addEventListener('message', (e) => {
const d = e.data;
if (!d || d.source !== 'localtcp_res') return;
const p = this._pending.get(d.messageId);
if (!p) return;
clearTimeout(p.timer);
p.resolve(d.response);
});
}
/* → {success, connected, version} */
checkBridge() { return this._send({ action: 'CHECK_BRIDGE' }); }
print(host, port, bytes) {
return this._send({ action: 'PRINT', host, port, data: bytes });
}
}
Encode ESC/POS bytes with any encoder, confirm the bridge, then send a plain array.
import EscPosEncoder from 'esc-pos-encoder';
import { LocalTcp } from './localtcp.js';
const printer = new LocalTcp();
// 1 · make sure the bridge is ready
const bridge = await printer.checkBridge();
if (!bridge.connected) return alert('Install Local TCP first.');
// 2 · build the receipt
const data = new EscPosEncoder()
.initialize().align('center').bold(true)
.line('ALGORAMMING CAFE').newline().cut()
.encode();
// 3 · print a PLAIN array, then close
await printer.print('192.168.1.50', 9100, Array.from(data));
Array<number>, using Array.from(uint8array). A raw Uint8Array doesn't survive the extension's JSON message hop and arrives malformed.The official package auto-detects the platform: on web it routes through this extension; on mobile/desktop it opens a direct socket. Your code is identical everywhere.
dependencies:
flutter_esc_pos_network_universal: ^1.1.0
| Platform | Transport | Extension? |
|---|---|---|
| Android · iOS · Win · macOS · Linux | Direct TCP | Not needed |
| Web | This extension | Required |
printTicket handles connect → print → disconnect. Give web extra timeout to wake a sleeping Wi-Fi printer.
final printer = PrinterNetworkManager(
'192.168.1.50', port: 9100,
paperSize: ThermalPosPrinterPageSize.size80mm,
timeout: const Duration(seconds: 30),
);
final g = Generator(PaperSize.mm80, profile);
final bytes = <int>[
...g.text('ALGORAMMING CAFE',
styles: const PosStyles(bold: true)),
...g.feed(2), ...g.cut(),
];
final result = await printer.printTicket(bytes);
printer.dispose(); // closes socket / removes web listener
printWidget(context, child: …). It renders to a bitmap and sends it as a single ESC/POS raster image, which is perfect for logos and QR codes. Package: flutter_esc_pos_network_universal.The bridge also prints to USB receipt printers, including the ones a browser can't reach on its own. Standard USB printers need no printer driver: the bridge uses the USB printer support already built into the operating system.
The popup's USB tab lists your receipt printers first, one row per printer, with its paper width when the model name tells it. Office printers (laser, inkjet, PDF, label) are folded away: raw ESC/POS would print as symbols on them.
| System | How the bridge prints | One-time setup |
|---|---|---|
| Windows | Straight to Windows' built-in USB printer driver, or through any installed Windows printer | None |
| Linux | Straight to /dev/usb/lp*, or through CUPS printers | The installer asks for your password once to allow USB printer access |
| macOS | Straight to the printer through macOS's built-in USB printing support, or through printers added in System Settings | None |
Plug it in with USB and switch it on.
In the extension popup, switch to USB. Your receipt printers are listed; press the refresh button after plugging one in.
Press Test receipt: it checks the paper width (32 or 48 characters), bold, underline, reverse, a QR code and the cutter. Optionally press Set as default: web apps that print without naming a printer use it.
Same client, two new actions. Save the printer's id together with its USB ids: if the printer moves to another USB port, match lets the bridge find it again.
const bridge = new LocalTcp();
// 1 · USB needs bridge v2.1.2+ (it reports features)
const info = await bridge.checkBridge();
if (!(info.features || []).includes('usb'))
return alert('Please update Local TCP.');
// 2 · find the printers the bridge can reach
const list = await bridge._send({ action: 'USB_LIST' });
// receipt printers come first: category "receipt"
const p = list.printers[0]; // { id, name, category, … }
// 3 · print ESC/POS bytes, base64 keeps receipts small
const res = await bridge._send({
action: 'USB_PRINT',
printerId: p.id,
match: { vendorId: p.vendorId, productId: p.productId,
serialNumber: p.serialNumber },
dataB64: btoa(String.fromCharCode(...bytes)),
});
if (!res.success) console.error(res.code, res.error);
The full contract for any client. Post to window with source: "localtcp_req" and a unique messageId; the response returns on a message event with source: "localtcp_res" and the same id.
| Field | Type | Notes |
|---|---|---|
source | string | must be "localtcp_req" |
messageId | string | unique id, echoed back |
action | string | see actions below |
host | string | printer IP on the LAN |
port | number | default 9100 |
data | number[] | ESC/POS bytes, a plain array |
readTimeoutMs | number | optional; wait for a device reply |
printerId | string | USB: an id from USB_LIST; omit to use the popup's default |
match | object | USB, optional: { vendorId, productId, serialNumber } |
dataB64 | string | USB: the bytes as base64 (smaller than data) |
timeoutMs | number | USB, optional: write timeout, default 20000 |
| Field | Type | Notes |
|---|---|---|
success | bool | overall result |
connected | bool | CHECK_BRIDGE: host reachable |
version | string | installed host version |
bytesSent | number | PRINT / SEND |
data | number[] | bytes read back on readTimeoutMs |
features | string[] | CHECK_BRIDGE: e.g. ["tcp","usb"] |
printers | object[] | USB_LIST: id, name, category (receipt · unknown · other), paperWidthMm, … |
code | string | USB failures: notFound, busy, timeout, … |
error | string | present on failure |
CHECK_BRIDGECONNECTPRINTSENDDISCONNECTUSB_LISTUSB_PRINTPING
A high-level alias is also accepted: { type: "LOCAL_TCP_PRINT", payload: { host, port, bytes, readTimeoutMs } }, where bytes maps to data. Concurrent jobs to the same printer are serialized so byte streams never interleave. USB failures also carry a stable code: notFound, busy, permissionDenied, timeout, ioError, noPrinter or bridgeOutdated.
Add the extension, then run the one-click installer for your OS. It registers the native host with every Chromium browser and auto-installs Node.js if it isn't already present. We've selected your platform below.
Install Local TCP from the Chrome Web Store. On first install it opens a setup tab and starts your download automatically.
Double-click localtcp-mac-installer.pkg → Continue → Install. macOS prompts for your password, then the host installs for your user account.
Quit Chrome completely and reopen it. The popup flips to Bridge Linked on its own, with no manual re-check.
Open the popup, enter your printer's IP and port (usually 9100), and hit Test Connection. For a USB receipt printer, plug it in, switch to the USB tab and press Test receipt; no driver and no System Settings step needed.
node keeps LAN access working under macOS 15/26 Local Network Privacy. If Node isn't installed, the installer fetches it for you.Installed to: ~/Library/Application Support/LocalTCP/index.js · manifest registered in each browser's NativeMessagingHosts/
Install Local TCP from the Chrome Web Store, then download the installer from the popup's Download Setup Kit button.
Double-click localtcp-windows-installer.exe → Install. No admin rights needed; it installs per-user.
Close every Chrome window and reopen. The popup shows Bridge Linked automatically.
Enter the printer IP and port in the popup and click Test Connection. For a USB printer, switch to the USB tab and press Test print; no printer driver is needed.
Installed to: %APPDATA%\Algoramming\LocalTCP\run_bridge.bat (plus usb_windows.ps1, the USB printer helper) · registered under HKCU registry keys
Install Local TCP from the Chrome Web Store and download the installer from the popup.
From your download folder:
chmod +x localtcp-linux-installer.run
./localtcp-linux-installer.runFully quit Chrome/Chromium/Brave and reopen. The popup reports Bridge Linked.
Set the printer IP/port in the popup and press Test Connection. For a USB printer, switch to the USB tab and press Test print.
Installed to: ~/.local/lib/algoramming/localtcp/index.js · manifest registered in each browser's NativeMessagingHosts/ · USB access rule /etc/udev/rules.d/70-localtcp-usb-printers.rules
In the extension popup, click Uninstall Setup Kit to download the uninstaller for your OS, then run it. To remove the extension itself, use Remove Extension in the popup.
Open the popup → Uninstall Setup Kit, or download the .pkg above.
Double-click localtcp-mac-uninstaller.pkg → Continue → Install → enter your password → Done. It removes the host and browser registrations.
Click Remove Extension in the popup, or manage it at chrome://extensions.
Run localtcp-windows-uninstaller.exe, or Start Menu → Uninstall Local TCP Bridge, or Settings → Apps → Local TCP → Uninstall.
The uninstaller stops the USB printer helper if it is running, removes the host files and clears the HKCU registry keys for every browser.
Use Remove Extension in the popup, or chrome://extensions.
From the popup → Uninstall Setup Kit, or download the .run above.
chmod +x localtcp-linux-uninstaller.run
./localtcp-linux-uninstaller.runIt also removes the USB printer access rule, so it may ask for your password.
Click Remove Extension in the popup, or open chrome://extensions.
Local TCP Bridge is built and maintained by Algoramming Systems Ltd., a software house that specialises in connecting modern web applications with the physical hardware that runs real businesses: point-of-sale, thermal printing, and networked devices.
Local TCP Bridge began as a piece of Algonize, a business platform that needed the browser to print straight to local hardware. Solving that once turned into a tool anyone can use, so we opened it up.
Explore Algonize www.algonize.xyz