# Invoicing

A free, open-source invoicing app template for freelancers and small businesses, built with Next.js, TypeScript and PostgreSQL. It covers quotes that clients accept online, UK VAT invoices in any currency, a signed page per invoice with a PDF and card payment through Stripe, part payments, credit notes, recurring invoices, aged receivables and CSV exports for your accountant.

- Framework: Next.js (JavaScript)
- Category: Apps / Invoicing and finance
- Creates: a server app and a PostgreSQL database on the Shared tier (1 GB)
- Plan: Lite or above
- Price: Free
- Author: Light Cloud
- Page: https://templates.light-cloud.com/apps/finance/invoicing-template-nextjs
- Updated: 2026-11-21

## Features

- Invoices with saved items, a discount and VAT rate per line (20%, 5%, 0% or outside the scope) and VAT totals per rate
- Numbers such as INV-2026-0042 given only when a document is sent, under a database lock, and sent invoices voided or credited, never edited
- Quotes that clients accept or decline from their link, then turn into a draft invoice in one click
- A signed client page per document with the amount due, bank details and an A4 PDF made with React PDF
- Pay by card through Stripe Checkout once STRIPE_SECRET_KEY is set, recorded on the invoice when the client returns
- Part payments, credit notes, and monthly or quarterly recurring invoices created as drafts for you to check and send
- Dashboard with outstanding, overdue and paid totals per currency, aged receivables in 30-day bands and cash per month
- CSV of invoices and payments for a month, quarter or UK tax year, and a year of demo data removed in one click

## What you need

- A paid plan: deploying creates a PostgreSQL database, which the Free plan does not include
- To run it locally: Node.js 22.12 or newer, npm, and Docker for a local PostgreSQL
- No API keys: it starts with nothing to configure, and clients pay by bank transfer from their invoice link
- Optional: STRIPE_SECRET_KEY for Pay by card, and STRIPE_PAYMENTS_WEBHOOK_SECRET to record payments when the client closes the tab
- Optional: RESEND_API_KEY and EMAIL_FROM to email invoices, quotes and reminders with the PDF attached

## About

The app is built on the Next.js SaaS starter: workspaces, roles, Better Auth sign-in and an admin panel, with invoicing in src/lib/invoicing. Money is stored as whole pence or cents, and what a document is today (overdue, partially paid, expired) is worked out from its dates, payments and credit notes each time it is shown, so nothing runs overnight. Recurring schedules create their drafts when you open the dashboard, invoices or recurring pages; they are not sent automatically. It is not a VAT return tool: export the CSV for your accountant or bookkeeping software. npm start applies the SQL migrations under a PostgreSQL advisory lock and seeds the Bristol Web Design Studio demo once, and the first person to sign up owns it; start with Settings, Business for your bank details, numbering and VAT rates.

## Variables

- `AUTH_SECRET`: generated

## Questions

### Is there a free, open-source invoicing app I can host myself?

Yes. This Next.js and PostgreSQL template is MIT licensed and runs on any Node.js host with PostgreSQL, or on Light Cloud in one click. Without any keys every invoicing feature works: clients pay by bank transfer and you share each invoice's link yourself.

### How do I generate invoice PDFs in Next.js?

This template renders them on the server with @react-pdf/renderer in a route handler, src/app/i/[token]/pdf/route.ts, from the same view model as the web page, so the PDF and the page always agree. The same PDF is attached when an invoice is emailed.

### How do clients pay an invoice online with Stripe?

Set STRIPE_SECRET_KEY and every unpaid invoice's client page shows Pay by card, which opens Stripe Checkout for the amount still owed. The payment is checked with Stripe and recorded once when the client comes back; add STRIPE_PAYMENTS_WEBHOOK_SECRET to record it even if they close the tab.

### Does it handle UK VAT invoices, credit notes and invoice numbering?

Yes. Each line has a VAT rate, VAT is shown per rate with its net amount, both VAT numbers are printed, numbers run per year without gaps, and mistakes are fixed with a void or a credit note rather than by editing a sent invoice. It does not file VAT returns: export the CSV for your accountant.

### Can it send recurring invoices automatically?

Not yet. A monthly or quarterly schedule creates a draft invoice on the right date, including month ends such as 28 February, for you to check and send. You can pause, resume or delete each schedule.
