<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Peng Shen</title>
    <description>The latest articles on DEV Community by Peng Shen (@peng_shen_138ab2aff61b0d4).</description>
    <link>https://dev.to/peng_shen_138ab2aff61b0d4</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4039230%2Fa4f63e4b-ba50-46d1-8f39-b2357da771c8.png</url>
      <title>DEV Community: Peng Shen</title>
      <link>https://dev.to/peng_shen_138ab2aff61b0d4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/peng_shen_138ab2aff61b0d4"/>
    <language>en</language>
    <item>
      <title>I built a VAT/GST invoice generator with zero backend — here's how</title>
      <dc:creator>Peng Shen</dc:creator>
      <pubDate>Tue, 21 Jul 2026 05:37:13 +0000</pubDate>
      <link>https://dev.to/peng_shen_138ab2aff61b0d4/i-built-a-vatgst-invoice-generator-with-zero-backend-heres-how-51on</link>
      <guid>https://dev.to/peng_shen_138ab2aff61b0d4/i-built-a-vatgst-invoice-generator-with-zero-backend-heres-how-51on</guid>
      <description>&lt;p&gt;Most invoice tools want you to create an account, they upload your client data to their servers, and they cost real money to run. I wanted the opposite: a tool that runs &lt;strong&gt;entirely in the browser&lt;/strong&gt;, keeps invoice data on the user's device, and costs me close to nothing to operate.&lt;/p&gt;

&lt;p&gt;It turned into &lt;a href="https://getcrossbill.com" rel="noopener noreferrer"&gt;Crossbill&lt;/a&gt; — a free VAT/GST invoice generator. Here's the architecture and the genuinely interesting bits, including the one that surprised me: &lt;strong&gt;even the paid tier needs no backend.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The constraint: no server, at all
&lt;/h2&gt;

&lt;p&gt;The whole thing is a static site — Next.js with &lt;code&gt;output: 'export'&lt;/code&gt; — deployed on Cloudflare Pages. There's no server, no database, and no auth. Editing, tax logic, and PDF generation all happen client-side, and the invoice data (clients, rates, amounts) lives in &lt;code&gt;localStorage&lt;/code&gt;. It never leaves the device.&lt;/p&gt;

&lt;p&gt;The nice side effect: marginal cost is basically zero, so I can leave the core free forever without it costing me per-user.&lt;/p&gt;

&lt;h2&gt;
  
  
  Money math without floating point
&lt;/h2&gt;

&lt;p&gt;The first thing that bites you when you sum line items is floating point:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="mf"&gt;0.1&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mf"&gt;0.3&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Do that across a dozen invoice lines with tax and discounts and you'll be a cent off in ways that look unprofessional. So all the math is done in &lt;strong&gt;integer cents&lt;/strong&gt; and only converted back at the edge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toCents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fromCents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;c&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// quantity can be fractional (e.g. 1.5 hours); round the product to whole cents&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;lineTotalCents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
  &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;qty&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Formatting is left to &lt;code&gt;Intl.NumberFormat&lt;/code&gt; so 25+ currencies get correct symbols, grouping and decimal digits (JPY has 0, most have 2) for free.&lt;/p&gt;

&lt;h2&gt;
  
  
  Generating the PDF in the browser
&lt;/h2&gt;

&lt;p&gt;No headless Chrome, no server render — &lt;a href="https://github.com/parallax/jsPDF" rel="noopener noreferrer"&gt;jsPDF&lt;/a&gt; plus &lt;code&gt;jspdf-autotable&lt;/code&gt; draw the invoice directly. One gotcha: some currency symbols render as tofu boxes in the default PDF fonts, so inside the PDF I use the unambiguous ISO-code form (&lt;code&gt;EUR 1,200.00&lt;/code&gt;) instead of the glyph — which is arguably clearer for cross-border invoices anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  The actual hard part: tax compliance, as data
&lt;/h2&gt;

&lt;p&gt;Here's the thing — the arithmetic isn't the hard part. Any tool can multiply a subtotal by a rate. The part cross-border freelancers actually fear getting wrong is the &lt;strong&gt;required fields and wording&lt;/strong&gt; per jurisdiction.&lt;/p&gt;

&lt;p&gt;So each jurisdiction is just a plain config object, and switching it rewrites both the form and the document:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;eu-rc&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;docTitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Invoice (Reverse Charge)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;taxLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;VAT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;defaultRate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;sellerTaxIdLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Your VAT ID&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;buyerTaxIdLabel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Customer VAT ID (VIES)&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;buyerTaxIdRequired&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;complianceNote&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Reverse charge: VAT to be accounted for by the recipient &lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;(Article 196, Council Directive 2006/112/EC).&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add AU GST (10%, "Tax invoice", ABN, "Total price includes GST"), UK VAT (20%, sequential numbering, VAT reg number), Canada GST/HST, US 1099, and the German Kleinunternehmer §19 UStG statement, and the "differentiator" is really just well-researched static data. Which is a nice reminder that a moat can be &lt;em&gt;content&lt;/em&gt;, not code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Monetization with no backend either
&lt;/h2&gt;

&lt;p&gt;This is the part I didn't expect to work. I assumed the paid tier would force me to stand up a server. It didn't.&lt;/p&gt;

&lt;p&gt;The Pro unlock is a one-time &lt;a href="https://www.lemonsqueezy.com/" rel="noopener noreferrer"&gt;Lemon Squeezy&lt;/a&gt; purchase that issues a &lt;strong&gt;license key&lt;/strong&gt;. You validate that key &lt;strong&gt;client-side&lt;/strong&gt; against Lemon Squeezy's public endpoint — no secret key, and it's CORS-friendly, so the browser can call it directly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.lemonsqueezy.com/v1/licenses/validate&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;POST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Content-Type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;license_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;unlockPro&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On success the license is stored in &lt;code&gt;localStorage&lt;/code&gt; and the Pro features light up. No backend of mine anywhere in the flow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tradeoffs I accepted
&lt;/h2&gt;

&lt;p&gt;I'd rather be upfront about these than pretend they don't exist:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The license check is client-side, so it's bypassable.&lt;/strong&gt; For a $29 impulse tool, a server to stop piracy would cost more (in money and in the zero-backend promise) than the piracy it prevents. Accepted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;localStorage&lt;/code&gt; means switching devices or clearing your browser loses your data.&lt;/strong&gt; A JSON export/import gives you a copy you own.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The tax presets are a convenience sourced from official guidance, not tax advice.&lt;/strong&gt; There's a disclaimer in the UI and the PDF.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Result
&lt;/h2&gt;

&lt;p&gt;It's live at &lt;strong&gt;&lt;a href="https://getcrossbill.com" rel="noopener noreferrer"&gt;getcrossbill.com&lt;/a&gt;&lt;/strong&gt; — free, no signup, runs in your browser. If you invoice under a jurisdiction I've modelled wrong, or one I should add, I'd genuinely like to know.&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the client-side/no-backend approach in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>nextjs</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
