The problem

The deal with most free PDF sites is one you didn't agree to: you drop a contract into a form, it flies to a server you've never heard of, gets processed in a queue, and you download the result while trusting the copy was deleted. For a holiday photo, nobody thinks twice. For the scanned passport, the medical bill, the NDA, it's a bad trade.

So we built PDF Smart Kit the other way around: 35 tools, and the server never sees a document. This is how that's structured, what turned out to be interesting about it, and where browser-side processing stops being enough.

Architecture: a static site with no document endpoint

The site is a Next.js app built with output: "export" (next.config.ts:88) and deployed to Cloudflare Pages through wrangler pages deploy out (the deploy:cf script in package.json). What ships is HTML, CSS, JS, and a few engine assets: public/pdf.worker.min.mjs, public/standard_fonts/, public/ocr/, public/resvg.wasm.

On pdfsmartkit.org, the Pages Functions in functions/ are the entire server surface:

  • api/feedback.js — the feedback form (text only, sent through Resend)
  • geo.js — returns the visitor's country code so consent logic knows whether a banner is legally required
  • _middleware.js — canonical-host 301s, retired-slug redirects, markdown negotiation
  • mcp.js, a2a.js, agent/identity.js, claim.js — agent protocol endpoints, covered below
  • .well-known/http-message-signatures-directory.js — the bot-auth key directory

None of them has a route that accepts a file. There is no upload endpoint to leak, log, or accidentally cache.

Processing happens where the file already is. Every tool page renders one client component, src/components/tool-shell/index.tsx, driven by a declarative registry (src/tools/registry.ts): slug, category, input/output kinds, and an options array of typed fields — text, select, range, number, plus showWhen conditionals so a tool can ask for one thing at a time instead of showing every mode's inputs at once. Clicking run lazily imports runTool() from src/tools/processors.ts (index.tsx:1006), which dispatches on the slug. Heavy page operations — merge, split, rotate, protect, crop — are posted to a module web worker (src/lib/pdf/run-heavy.ts:49) so the tab stays responsive on a thousand-page scan, with an inline fallback if workers are unavailable or crash.

The libraries are all local: pdf.js for rendering and text extraction, pdf-lib for page-level surgery, mammoth's browser build for .docx, xlsx for spreadsheets, pptxgenjs for slides, JSZip for containers, tesseract.js for OCR, resvg-wasm for SVG-to-PNG. The data path is File → arrayBuffer → worker → Blob → download (with an inline fallback when workers are unavailable). Grep fetch( across src/ finds five call sites in app code: /geo, /api/feedback, an image URL the user pasted, a same-origin asset, and an external image referenced by HTML the user is converting. None of them carries document bytes.

The engineering that was actually interesting

A strict CSP that still lets WASM run

public/_headers:8 ships one CSP for the whole origin: default-src 'self', object-src 'none', frame-ancestors 'none', and a script-src of 'self' 'unsafe-inline' 'wasm-unsafe-eval' blob: …. The token that matters is wasm-unsafe-eval. Under a strict CSP, WebAssembly.compile/instantiate is blocked the same way eval() is — and every engine here is WASM: pdf.js's image decoders, tesseract's OCR core, resvg. wasm-unsafe-eval reopens exactly that one door, and only that one door: WebAssembly instantiation is allowed, JavaScript eval() stays blocked. The rest of the line is load-bearing too — worker-src 'self' blob: covers the module worker and the OCR worker, and blob: in frame-src is for the print iframe.

A service worker that refuses to pin you to an old build

Navigations are network-first (public/sw.js:75). Deployments are frequent and the HTML embeds hashed asset names plus inline CSS, so cache-first HTML would hand returning visitors a stale shell against new /_next/static files. The cached copy exists only as an offline fallback, and a 5xx falls back to what that visitor already had rather than to an error page. Two more caches ride alongside: App Router flight payloads (keyed with the _rsc cache-buster stripped) and /pdf.worker.min.mjs itself, so a connection that drops mid-session can still open a document instead of failing pdf.js's dynamic import.

The rule the code enforces is that no branch may reject — every path settles on a Response, the network's, the cache's, or a synthesized offline page built from inline styles and a data-URI favicon (a favicon that 404s offline shows a blank tab). The real sw.js is executed under node:vm with mocked caches in src/lib/service-worker.test.ts, so the offline-navigation contract is tested against the file that actually ships.

35 tools, one shell, one pipeline

The registry is the product: 10 Organize, 4 Edit, 19 Convert, 2 Security — 35 entries, each a plain object carrying SEO titles, HowTo steps and FAQs next to input, output and options. The shell reads that declaration and builds the form, the validation, the result panel and the download; runTool() is a switch over slugs. Adding a tool is mostly data entry. An agent-facing catalog mirrors the registry and a test keeps the two in lockstep (src/lib/agent-tools.test.ts), so a new tool cannot ship without the endpoints knowing about it. The UI side is covered by 31 Playwright spec files that run on Chromium, WebKit and Firefox on every run (playwright.config.ts).

Agent endpoints on a site with no backend

This is the part we didn't expect to be novel. functions/mcp.js is a stateless MCP server over Streamable HTTP — initialize, tools/list, tools/call — advertising two tools that search the catalog and hand back tool URLs. functions/a2a.js answers JSON-RPC message/send with a routing message and serves an agent card on GET. Both read from src/lib/agent-tools.ts, and both are deliberately limited: they cannot receive or process a file, and the code says so out loud. A static site running an MCP endpoint is odd; a static site whose MCP endpoint can't touch documents is the only honest shape for this architecture.

The same idea shows up in content negotiation. scripts/build-markdown.mjs writes a .md sibling for every exported page at build time, and functions/_middleware.js:95 serves it when a request arrives with Accept: text/markdown. Browsers never send that header for navigations; agents do. Conversion happens at build time, so request-time CPU stays at zero on the free plan — the middleware only ever serves a file it already has.

Honest limits

  • Memory, not quotas. With no server queue to offload to, the ceiling is the device. Inputs above 1 GiB are rejected before they can crash the tab (MAX_TOTAL_INPUT_BYTES, src/components/tool-shell/constants.ts:88), and the error mapper turns the browser's "out of memory" into plain language.
  • The tab has to stay open. No background jobs, no "convert while you're away", no server-side history. Close the tab and the run is gone.
  • OCR is English-only and pays a cold start. The worker loads eng traineddata from our own origin (src/lib/pdf/ocr.ts:44); first use fetches a ~4.7 MB WASM core and ~11 MB of gzipped trained data, so the first recognition takes seconds and later runs don't.
  • "No upload" is not "no network." Assets come from our origin, Cloudflare's analytics beacon is injected into Pages HTML, and GA4 loads only after consent, with events limited to a fixed vocabulary that never includes file names. Two features fetch a URL on your behalf — an image you paste, and external images inside HTML you're converting — and both need the remote host to allow the read: the pasted image is held to the same 1 GiB input ceiling, the HTML-embedded ones to 10 MB and 15 seconds.
  • No account means no sync. Nothing to log into is the privacy feature; it's also why there's no cross-device history to restore.

Try it

Everything above is the same claim you can verify with devtools open: pick a file, watch the network tab, and see that no request carries it. The tools are at pdfsmartkit.org — merge, split, compress, convert, protect, and the rest of the 35, free and with no sign-up.

— PDF Smart Kit (pdfsmartkit.org)