{
  "id": 22960248,
  "title": "I built 23 UK energy cost calculators with Next.js, and the hard part wasn't the code",
  "url": "https://urgent.news/2026/12/01/i-built-23-uk-energy-cost-calculators-with-next-js-and-the-hard-part",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-01T13:39:06.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/ammad_khan_2e45c01512aa64/i-built-23-uk-energy-cost-calculators-with-nextjs-and-the-hard-part-wasnt-the-code-11fm"
  },
  "original_language": null,
  "account": "I embarked on constructing 23 UK energy cost calculators using Next.js, and the most challenging aspect turned out not to be the coding. The project, named Home Running Costs, comprises a collection of free calculators for UK household expenses: the hourly cost of heaters, whether heat pumps are more cost-effective than gas boilers, the price of 1,000 litre oil deliveries this week, and the implications of the energy price cap on individual usage. The site now accommodates 23 calculators and 8 guides. The technology stack is straightforward: Next.js (App Router, static export), React, TypeScript, Vitest, and Cloudflare for hosting. The primary focus was on ensuring numerical accuracy, as prices change every three months, governed by Ofgem's price cap, which adjusts quarterly. For instance, on January 1, 2027, electricity rates will rise from 26.32p to 32.69p per kWh, while heating oil prices fluctuate weekly, and water bills change in April. To maintain data integrity, I established a rule: every figure resides in a single configuration file, along with its source and the date it was verified. This configuration file is named src/config/uk.ts (summarized). The configuration exports UK-specific data, including electricity and gas unit rates, standing charges, and the period for which these rates are applicable. Pages within the application never hardcode prices. Instead, the content is dynamically generated from the configuration. For example, the text \"At today's price cap of {uk.electricity.unitRatePence}p per kWh, a 400 W heater costs about {pence(perHour(400))} an hour\" is generated using the configuration. Regular tests verify the correctness of the calculations, but the most valuable tests confirm the accuracy of the data against published figures. For example, a test checks that the calculator for January 2027's price cap, which Ofgem estimates to be £2,166 a year for a typical home, returns the expected result. If a rate is mistyped, the build process fails instead of the site displaying incorrect bills. Similar tests ensure that each calculator includes a chart, a share image, and at least one authoritative source link. The site is statically exported at build time, ensuring fast loading times and low hosting costs. Query strings in the URL store calculator inputs, allowing results to be shared or bookmarked, for example, /uk/electric-heater-running-cost/?preset=custom&watts=600&hoursPerDay=5. A small useUrlState hook manages these values, with a whitelist for enum inputs to prevent broken UI states. In addition to functionality, I paid attention to user experience and SEO. Each calculator page begins with a concise answer to the user's query, followed by the calculator. These answers also serve as FAQ schema entries, and each page contains structured data linking it to relevant topics. These elements are straightforward but often overlooked when the focus is solely on the calculator. I advise anyone undertaking a similar project to treat data as the core product. The user interface is relatively simple, but ensuring the data's accuracy and provenance is crucial for the calculator's credibility. Implementing a build failure for any incorrect data and regularly testing the data against official sources can catch more bugs than numerous unit tests. It is essential to plan for updates from the outset. If a price change requires editing more than one file, it is highly likely that it will be done incorrectly at some point. By treating data as the product and ensuring updates are manageable, the site becomes more trustworthy and reliable. For those interested in exploring the site further, visit homerunningcosts.com. I welcome any questions about the project's setup in the comments.",
  "summary": "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,…",
  "summary_source": "publisher",
  "key_points": [],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}