A few months ago I started building Home Running Costs, a set of free calculators for UK household bills: what a heater costs per hour, whether a heat pump beats a gas boiler, how much a 1,000 litre oil delivery costs this week, what the energy price cap means for your own usage.
It's now 23 calculators and 8 guides. The stack is boring on purpose: Next.js (App Router, static export), React, TypeScript, Vitest, and Cloudflare for hosting. The interesting problems were all about numbers going out of date.
The real problem: prices change every three months
UK energy prices are set by Ofgem's price cap, which changes every quarter. On 1 January 2027 electricity goes from 26.32p to 32.69p per kWh. Heating oil prices move weekly. Water bills change every April.
If those numbers are scattered through 23 pages of JSX, one of them will be wrong within a quarter. So the rule I set early on was:
Every figure lives in one config file, with its source and the date it was checked.
// src/config/uk.ts (simplified) export const uk = { electricity: { unitRatePence: 26.32, standingChargePencePerDay: 54.83 }, gas: { unitRatePence: 7.97, standingChargePencePerDay: 29.68 }, ratesPeriod: "1 October – 31 December 2026", ratesSource: { url: "https://www.ofgem.gov.uk/..." }, // ...heating oil, water, council tax, battery prices, etc. }; Pages never hard-code a price. Even the prose is built from the config:
<p> At today's price cap of {uk.electricity.unitRatePence}p per kWh, a 400 W heater costs about {pence(perHour(400))} an hour. </p> When the cap changes, I update one file and every calculator, table, FAQ answer and chart follows.
Tests that check the facts, not just the code
The test suite (Vitest) does the usual "the maths is right" checks, but the most useful tests check the data against the published figure. For example, Ofgem said the January 2027 cap is £2,166 a year for a typical home. So there's a test that runs my calculator with Ofgem's typical usage and expects exactly that:
it("reproduces Ofgem's announced next cap for a typical home", () => { const r = calculatePriceCap(priceCapDefaults); expect(Math.floor(r.nextAnnual)).toBe(uk.nextCap.typicalBill); // 2166 }); If I mistype a rate, the build fails instead of the site quietly showing a wrong bill. There are similar guard tests for things that are easy to forget: every calculator must have a chart, a share image and at least one authoritative source link.
Static export, but still shareable results
Everything is pre-rendered at build time, so pages are fast and cheap to host. Calculator inputs are kept in the URL query string, so a result can be shared or bookmarked:
/uk/electric-heater-running-cost/?preset=custom&watts=600&hoursPerDay=5 A small useUrlState hook reads and writes those values, with an allow-list for enum inputs so random query strings can't put the UI in a broken state.
Writing for people (and search engines)
Each calculator page starts with a short, direct answer before the calculator, because that's what people actually want ("How much does a 2 kW heater cost per hour?"). The same answers feed FAQ schema, and each page has structured data linking it to the topics it covers. None of that is clever, but it's easy to skip when you're focused on the calculator itself.
What I'd tell anyone building something similar
- Treat your data as the product. The UI is the easy bit. Knowing where every number came from, and when, is what makes a calculator trustworthy.
- Make wrong data fail the build. A test that compares your output to an official published figure catches more real bugs than ten unit tests.
- Plan for updates from day one. If a price change means editing more than one file, it will eventually be done wrong.
The site is homerunningcosts.com if you want to poke at it. Happy to answer questions about the setup in the comments.
