Add Receipt Printing to a Lovable, Bolt or Replit App in 10 Minutes

An AI builder chat writing a print-receipt function that prints a receipt on a thermal printer

To add receipt printing to a Lovable, Bolt or Replit app, give the app one server-side function that sends a signed POST /jobs to the BizPrint Print API, and a BizPrint station at the counter prints the receipt on a real thermal printer with no browser dialog and nobody clicking Print. The whole job is: paste one prompt into your AI builder, put two API keys in your project’s secrets (never in the browser code), let the tool write a small edge function or server route, and send it the URL of a receipt page. This guide gives you the prompt, the function the AI should produce for each of the three tools, the place each tool keeps the secret key, how to test without using up free prints, and the errors you will hit on the first run. To add printing to a Lovable app, start with the prompt.

Paste this into Lovable, Bolt or Replit’s agent chat (or Cursor, or any tool that writes server-side code):

Add receipt printing to this app using the BizPrint Print API.

Setup
- Base URL: https://print.bizswoop.app/api/connect-application/v1
- Store BIZPRINT_PUBLIC_KEY and BIZPRINT_SECRET_KEY as server-side secrets.
  Never send the secret key to the browser and never put it in a VITE_ variable.

Request signing
- POST: add "publicKey" and "time" (Unix seconds) to the JSON body, serialize it once,
  compute SHA-256 of "<serialized body>:<secret key>" as hex, and send the same body
  with that digest added as "hash". Header: Content-Type: application/json.
- GET: add publicKey and time as query parameters, hash the query string the same way,
  append it as "hash".

Endpoints
- GET /printers → list printers (each has a numeric id)
- POST /jobs with { printerId, url, description } → creates a job, returns { id, status }
- GET /jobs/{id} → status: pending, processing, connecting-to-printer, done, failed

What to build
1. A server-side function "print-receipt" that takes { orderId, printerId }, builds the
   receipt URL for that order, and calls POST /jobs. The browser calls this function,
   never the BizPrint API directly.
2. A page at /receipts/:orderId?t=<unguessable token> that renders the receipt as plain
   HTML, 80mm wide, no images, for a thermal receipt printer.
3. A "Print receipt" button on the order screen that calls the function and shows the
   job status.
Handle errors by reading errorCode and message from the JSON error body.

What the tool should write for Lovable or Bolt is a Supabase-style edge function like this one. It is the only piece that touches the secret key, and it runs on the server, not in the user’s browser:

// supabase/functions/print-receipt/index.ts — Lovable Cloud / Bolt server function / any Supabase project
const API = "https://print.bizswoop.app/api/connect-application/v1";
const PUBLIC_KEY = Deno.env.get("BIZPRINT_PUBLIC_KEY")!;
const SECRET_KEY = Deno.env.get("BIZPRINT_SECRET_KEY")!;
const APP_URL = Deno.env.get("APP_URL")!; // e.g. https://my-orders.lovable.app

async function sign(serialized: string): Promise<string> {
  const bytes = new TextEncoder().encode(`${serialized}:${SECRET_KEY}`);
  const digest = await crypto.subtle.digest("SHA-256", bytes);
  return [...new Uint8Array(digest)].map((b) => b.toString(16).padStart(2, "0")).join("");
}

Deno.serve(async (req) => {
  const { orderId, printerId, token } = await req.json();
  const body = {
    printerId: Number(printerId),
    url: `${APP_URL}/receipts/${orderId}?t=${token}`,
    description: `Receipt #${orderId}`,
    publicKey: PUBLIC_KEY,
    time: Math.floor(Date.now() / 1000), // seconds, not milliseconds
  };
  const serialized = JSON.stringify(body);
  const hash = await sign(serialized);
  const res = await fetch(`${API}/jobs`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ ...body, hash }),
  });
  const json = await res.json();
  return new Response(JSON.stringify(res.ok ? json.data : json), {
    status: res.status,
    headers: { "Content-Type": "application/json" },
  });
});

A successful call returns a job object with status: "pending"; a few seconds later the status is done and the receipt is in the tray. The endpoint, the body fields and the signing rule come from the BizPrint HTTP reference and the developer docs; the Node version of the same call is in the Print API guide.

Key Takeaways

  • One server-side function is the whole integration. The browser calls your function; your function signs a POST /jobs to the BizPrint Print API; a station at the counter prints it. The AI builder writes the function from the prompt above.
  • The secret key never reaches the browser. In Lovable it lives in More → Settings → Secrets, in Bolt in the project’s Secrets panel, in Replit in Tools → Secrets; all three expose it only to server-side code.
  • The receipt is just a web page. Render the order as plain HTML at an unguessable URL and send that URL in the job; BizPrint fetches and prints it, so your AI tool only has to style a page, which it already does well.
  • Signing is one SHA-256 and two rules. Serialize the body once, hash "<body>:<secret>", and send the time field in seconds; almost every ERR_UNAUTHORIZED is one of those two rules broken.
  • Development mode makes testing free. Every account starts with 25 free prints and no card; turning on development mode lifts that limit while you build, so you can iterate on the receipt layout without counting prints.
  • Use window.print() instead when the browser is enough. If a person is always at the screen with a desktop printer attached, the browser dialog is fine; the Print API is for printing where nobody is at the screen, on receipt and label printers.

What do you need before you start?

You need a BizPrint account with a printer online, your two API keys, and an app that already has a server side, which in Lovable and Bolt means a connected database with edge functions and in Replit means any backend route. Nothing here needs a credit card: the 25 free print jobs and development mode cover the build.

RequirementLovableBoltReplit
Where the secret key livesMore → Settings → Secrets (write-only; injected into edge functions, never the browser)Database icon → Secrets (read only by server functions, never written into project files)Tools → Secrets (exposed as environment variables to your backend; published apps have their own Production app secrets)
Where the print function runsLovable Cloud / Supabase edge function (Deno)Bolt server function on a connected Supabase database (Deno)Your Node, Python or other backend route
What must be true firstA backend is enabled for the projectA database is connected (Secrets needs one)The project has a server, not a static site
How the browser calls itsupabase.functions.invoke("print-receipt", { body })The same invoke callfetch("/api/print", { method: "POST" })
Public-variable trapVITE_ values are built into the client bundle; the Secrets manager rejects them.env values are readable by browser code and ship to visitorsStatic Deployments cannot read Secrets

The rows come from each tool’s own documentation: Lovable secrets, Bolt secrets and Replit secrets. The common thread is the one that matters: in all three tools the secret key has a home that only server-side code can read, and your prompt must say so, because an AI builder that is not told otherwise will happily put the key in a frontend constant.

On the BizPrint side you need three things from BizPrint Cloud: an application on the Applications page, which issues the public key and the secret key; a station (the BizPrint app on a Windows, macOS, Linux or Raspberry Pi OS computer, or an Android device for ESC/POS and StarPRNT receipt printers) signed in at the location; and the numeric ID of the printer attached to it, which you read from the Printers list or from GET /printers.

Flow from the order screen to a server-side print function, BizPrint Cloud, the station and the printer
The browser calls your function, your function makes one signed call with the secret key, and the station at the counter fetches the receipt page and prints it.

How do you add printing to a Lovable app, step by step?

You add printing to a Lovable app in six steps: create the keys, store them as secrets, paste the prompt, check the function Lovable writes, build the receipt page, and send a test job. The same steps work in Bolt; the Replit differences are in the next section.

  1. Create your API keys. Sign up at login.bizswoop.app/register, install a station on the computer or Android device next to the printer, and create an application in the dashboard; copy the public key and the secret key. Note the printer’s numeric ID from the Printers list.
  2. Store the keys as secrets, not variables. In Lovable, open More → Settings → Secrets and add BIZPRINT_PUBLIC_KEY and BIZPRINT_SECRET_KEY (you can also just tell the chat “I need to add a BizPrint secret key” and Lovable opens a secure input). In Bolt, open the database menu, choose Secrets, and save both under exactly those names. Add APP_URL with your published app’s URL so the function can build receipt links. Do not paste either key into the chat as plain text and do not let the tool create a VITE_BIZPRINT_SECRET_KEY.
  3. Paste the prompt. Use the prompt block at the top of this page as written. It tells the tool the base URL, the signing rule, the three endpoints and the three things to build. If the tool asks where the keys are, say they are already in Secrets under those names.
  4. Check the generated function against the sample. Open the edge function the tool wrote and compare it to the print-receipt sample above. Four things must match: it reads the keys with Deno.env.get, it adds publicKey and time to the body before hashing, time is Math.floor(Date.now() / 1000), and the hash is computed over the exact string it then sends. If the tool wrote an Authorization header or an HMAC, that is a guess; paste the signing paragraph from the prompt again.
  5. Build the receipt page. Ask the tool for a route at /receipts/:orderId that takes a t token, loads the order, and renders plain HTML about 80mm wide: store name, order number, line items, totals, a thank-you line, no images and no external fonts. The token is stored on the order when it is created and compared on the way in, so the page is unguessable but needs no login (BizPrint fetches it as an anonymous visitor).
  6. Send a test job from the order screen. Add a “Print receipt” button that calls supabase.functions.invoke("print-receipt", { body: { orderId, printerId, token } }) and shows the returned status. Click it: the function returns { id, status: "pending", ... }, and the receipt prints. Poll GET /jobs/{id} if you want to show done in the UI, or just trust the printer for a receipt.

Here is the browser-side call the tool should produce, so you can recognise it:

// In the order screen (Lovable / Bolt frontend). No keys here, on purpose.
const { data, error } = await supabase.functions.invoke("print-receipt", {
  body: { orderId: order.id, printerId: 12, token: order.receipt_token },
});
if (error) console.error("Print failed:", error);
else console.log("Job", data.id, "is", data.status); // "pending" → "done" in a few seconds
Six steps to add printing to a Lovable or Bolt app, from API keys to a test job

Ready to add printing to your app? Every BizPrint account starts with 25 free print jobs, no card required, and the Print API is included on every plan.

How is it different in a Replit app?

In Replit the print call is an ordinary backend route instead of an edge function, and the keys come from Tools → Secrets as environment variables. The prompt is the same; only the file the tool writes changes. For a Node app it should look like this:

// server/print.js — Replit, Node 20+. Keys from Tools → Secrets; no client-side access.
import express from "express";
import { createHash } from "node:crypto";

const API = "https://print.bizswoop.app/api/connect-application/v1";
const sign = (s) => createHash("sha256").update(`${s}:${process.env.BIZPRINT_SECRET_KEY}`).digest("hex");

const app = express();
app.use(express.json());

app.post("/api/print", async (req, res) => {
  const { orderId, printerId, token } = req.body;
  const body = {
    printerId: Number(printerId),
    url: `${process.env.APP_URL}/receipts/${orderId}?t=${token}`,
    description: `Receipt #${orderId}`,
    publicKey: process.env.BIZPRINT_PUBLIC_KEY,
    time: Math.floor(Date.now() / 1000),
  };
  const serialized = JSON.stringify(body);
  const r = await fetch(`${API}/jobs`, {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ ...body, hash: sign(serialized) }),
  });
  const json = await r.json();
  res.status(r.status).json(r.ok ? json.data : json);
});

app.listen(process.env.PORT || 3000);

Two Replit-specific notes. Secrets are available to every deployment type except Static Deployments, so the app must be published as a web server, not a static site. And a published Replit app has its own secrets: open Publishing → Adjust settings → Production app secrets and add the two BizPrint keys there too, or the live app will sign requests with an empty key and get ERR_UNAUTHORIZED while the workspace version works fine.

For Python on Replit, the same route is a Flask or FastAPI handler using hashlib.sha256 over the serialized body with separators=(",", ":") so the JSON has no spaces; the Python sample in the Print API guide is the one to point the tool at.

How do you test without using up your free prints?

Turn on development mode in your BizPrint Cloud dashboard and the 25-free-print limit no longer applies while you build and test. That is the setting to flip before you start iterating on the receipt layout, because a receipt page usually takes five or six prints to get right and you do not want the limit to surface as a confusing error in the middle of it.

A good test loop looks like this:

  1. Print the receipt page in a browser tab first. Open /receipts/<id>?t=<token> yourself. If it needs a login, BizPrint’s fetch will get the login page and you will print a login form. The page must render for an anonymous visitor who has the token.
  2. Send one job and read the response. status: "pending" with a numeric id means the request was accepted and signed correctly. Everything after that is station and printer.
  3. Poll the job once. GET /jobs/{id} moves through processing and connecting-to-printer to done or failed within seconds. failed with a station online usually means the printer is off, out of paper or on the wrong station.
  4. Check the paper, not the screen. Thermal printers cut and feed differently; set the page width to 80mm (or 58mm) and a single column, drop images and web fonts, and print again until the layout is right.
  5. Only then wire the trigger. Once a manual button prints a clean receipt, move the call to where it belongs: on order creation, on payment success, on a status change. The function does not change; only what calls it.
Five-step test loop for receipt printing with development mode turned on

When development mode is off again, you pay per successful print job and nothing else; the API is included on every plan, including the Build plan made for apps and agents, and current rates are on the pricing page.

What are the most common errors on the first run?

Most first-run errors are a signing mistake or a frontend that is calling BizPrint directly, and both are fixed by comparing the generated code to the sample rather than re-prompting blindly. The API returns a JSON body with errorCode and message, which is exactly the kind of output an AI builder can read and fix if you paste it back into the chat.

What you seeWhat it meansFix
401 ERR_UNAUTHORIZEDThe hash does not match. Nine times out of ten time is in milliseconds, or the body was re-serialized with different key order after hashing.Use Math.floor(Date.now() / 1000); hash the exact string you send; in Python set separators=(",", ":").
401 ERR_UNAUTHORIZED only in the published appThe live environment has no secrets.Replit: add them under Production app secrets. Lovable/Bolt: confirm the secrets exist in this project, not a fork.
403 ERR_JOB_CREATING_INVALID_PRINTER_ID (“Invalid printer ID”)The printer is not on your account, or you sent a name instead of a number.Read the numeric ID from the Printers list or GET /printers.
400 ERR_JOB_CREATING_PRINT_JOB_LIMIT (“Reached print limit”)The 25 free prints are used and development mode is off.Turn on development mode to keep testing, or choose a plan.
400 ERR_INVALID_REQUEST with an errors objectA required field is missing or the wrong type.printerId is a number; url and description are required strings.
Job done but the printout is a login page or a blankBizPrint fetched the URL and got something other than the receipt.The receipt route must render for an anonymous request carrying the token; check APP_URL is the published URL, not localhost.
Job stays pendingNo station is online for that printer.Open the station app at the location and confirm the printer is attached and online.
CORS error in the browser consoleThe frontend is calling print.bizswoop.app directly.Never do that; it would expose the secret. Call your own function and let it call BizPrint.
The tool created VITE_BIZPRINT_SECRET_KEYThe secret would ship in the client bundle.Delete it, add the key in Secrets, and tell the tool the key is server-side only.

The error codes and their HTTP statuses are listed in the BizPrint HTTP reference. The one that is not a BizPrint error at all, the CORS failure, is the one to watch for most, because it is the symptom of a secret about to leak.

When is window.print() enough, and when do you need a print API?

Use window.print() when a person is always at the screen with a desktop printer attached, and use a print API when the receipt has to come out of a thermal printer at a counter or kitchen with nobody clicking anything. That is the honest line, and it is worth drawing before you add a dependency.

SituationBrowser print (window.print() + @media print)Native wrapper (AirPrint)BizPrint Print API
A back-office user prints an invoice on an office printerFineUnnecessaryUnnecessary
A receipt must print at the counter when an order is paid, no clickNo: needs a person and a dialogNo: needs the device and a tapYes: a signed POST from your server
Thermal receipt or label printer (ESC/POS, StarPRNT)Unreliable: drivers, page sizes, silent-print hacksOnly if the printer supports AirPrintYes: Android stations speak ESC/POS and StarPRNT; desktop stations on Windows, macOS, Linux, Raspberry Pi OS
A kitchen ticket at a second locationNoNoYes: pick the printer ID for that location
An AI agent, cron job or webhook triggers the printNo browser at allNoYes: the same call; see the MCP server guide
The app is a prototype and you want proof on paper todayOnly if the printer is on the deskOnly on iOS/macOS devicesYes: 25 free prints, no card

The competing tutorials in this space frame printing from Lovable as office printing through a cloud print service’s MCP, and that is a reasonable path for a document that goes to a laser printer in an office. The difference with the Print API is the hardware and the trigger: receipt and label printers at a counter, fired by an event in your app or by an agent, which is what a point-of-sale, ordering or fulfillment prototype actually needs.

How do you go from a prototype to something you can run?

You harden it in four places, none of which change the print call: rotate the keys the prototype used, lock the function to signed-in users, make the receipt URL single-use or short-lived, and move the trigger server-side. The function you have is already the production shape, which is the point of doing it as a server-side call from the first prompt.

  • Rotate the keys. If a key was ever pasted into a chat or committed to a file, create a new application in BizPrint Cloud and replace the secrets. All three tools let you overwrite a secret without touching code.
  • Require a user on the function. Lovable and Bolt edge functions can verify the caller’s session token; make the print function reject anonymous requests so a stranger cannot print on your counter printer by calling the function URL.
  • Tighten the receipt token. Store a random token per order, compare it in the receipt route, and consider expiring it an hour after the job is done. BizPrint fetches the page once, at print time.
  • Trigger from events, not buttons. Move the call to the order-created or payment-succeeded handler so the receipt prints without a tap, and keep the button as a reprint.
  • Decide what prints where. One app, several printers: receipts at the counter, tickets in the kitchen, labels at packing. Each is the same call with a different printerId and a different page.

If the app outgrows a prompt-built function, the Print API guide covers every endpoint, the Node client the developer docs name, and pagination for job history. And if the thing calling your app is an agent rather than a user, the same API is exposed to Claude and other local MCP clients through the open-source BizPrint MCP Server, which runs locally (there is no hosted version); the MCP server guide and the category explainer on what a print MCP server is cover that path, and From Print API to MCP: Expose Your Print Workflow to Agents walks through exposing your own print workflow to agents. For a PrintNode-style comparison before you commit, see BizPrint vs PrintNode.

Frequently asked questions

How do I add a printer to print from my app?

Install the BizPrint station app on a computer (Windows, macOS, Linux or Raspberry Pi OS) or an Android device at the location, connect the receipt or label printer to it, and the printer appears in BizPrint Cloud with a numeric ID. Your app never talks to the printer; it sends a job with that ID to the Print API and the station prints it.

How do I connect a printer with an app built in Lovable?

Store your BizPrint public and secret keys in Lovable’s Secrets (More → Settings → Secrets), paste the prompt at the top of this guide, and let Lovable write a print-receipt edge function that signs a POST /jobs with the receipt page’s URL and the printer ID. The browser calls the function; the function calls BizPrint.

Can a Bolt app print to a thermal receipt printer?

Yes. Connect a database so Bolt’s Secrets panel is available, add the two BizPrint keys there, and have Bolt write a server function that calls POST /jobs. An Android station handles ESC/POS and StarPRNT receipt printers; desktop stations handle printers with drivers on Windows, macOS, Linux and Raspberry Pi OS.

Where should the API secret key live in a Replit app?

In Tools → Secrets, read by your backend as an environment variable, and again under Publishing → Adjust settings → Production app secrets for the published app. Never in a frontend file, and never in a Static Deployment, which cannot read Secrets at all.

How do I set up auto print when an order comes in?

Call your print function from the server-side event that creates or pays the order (a database trigger, a webhook handler or the order-creation route) instead of from a button. The call is identical; only the trigger moves. For WooCommerce and Shopify stores BizPrint does this with no code through its plugin and app.

What happens if I publish my Lovable app? Will printing still work?

Yes, as long as the secrets exist in the published project and APP_URL points at the published domain so receipt URLs are reachable by BizPrint. Secrets are injected into edge functions in production the same way as in preview; what breaks most often is a receipt URL still pointing at a preview or localhost address.

Can I test printing for free?

Yes. Every BizPrint account starts with 25 free print jobs and no card is required; turning on development mode lets you keep printing past that limit while you build and test, and you pay per successful print only once you are live. Rates are on the pricing page.

Which plan do I need for an AI-built app?

Any plan; the Print API is included on every plan at no extra fee. The Build plan is API and MCP only and is made for apps and agents that do not need the WooCommerce plugin (from Plus) or the Shopify app (Pro, billed through Shopify).

How do I print from an AI agent instead of an app?

Use the open-source BizPrint MCP Server, which exposes the same printers and jobs to Claude Desktop, Claude Code and other local MCP clients. It runs locally; there is no hosted version. The MCP server guide has the install step and the first prompt.

Ready to see your first receipt?

Create a BizPrint account, add the two keys to your project’s secrets, paste the prompt, and your Lovable, Bolt or Replit app can print a real receipt before you finish your coffee. The first 25 prints are free with no card, and development mode keeps the build free after that.