How I Built a Mortgage Calculator That Actually Helps People Save $200K+ (Next.js + Real Math)

Published: (January 17, 2026 at 11:04 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

The Problem: Financial Calculators That Don’t Actually Calculate Anything Useful

  • Basic math only (principal × rate × time).
  • No strategy comparison (what if I invest instead?).
  • Hidden behind email walls (give us your data first!).
  • No explanation of the math (black‑box calculations).
  • They don’t account for cash‑flow efficiency (Velocity Banking).

I’m a developer who understands compound interest, yet I couldn’t find a tool that answered: “Should I use a HELOC, make extra payments, or just invest the difference?”

So I built one. It accidentally turned into a product that’s helped 2,000+ users save an average of $142,000 in projected interest.

(Disclaimer: I am the creator of this tool. I built it to solve my own problem, and now I share the logic openly.)

The Math That Most Calculators Get Wrong

Most calculators use simple formulas that work for car loans but fail for mortgages because they ignore amortization schedules.

A mortgage front‑loads interest. A $100 extra payment in Year 1 saves significantly more than a $100 payment in Year 20.

To handle this, I built an engine that simulates the loan month‑by‑month, reacting to events like “Lump Sum Payment” or “HELOC Injection”.

The Tech Stack

Frontend

  • Next.js 14 (App Router) + TypeScript
  • Tailwind CSS + Shadcn UI

Backend / DB

  • Supabase (PostgreSQL)

Math

  • Custom engine + decimal.js for precise calculations

Real‑Time Reactivity

// app/calculator/page.tsx (Simplified)
import { useState, useEffect } from 'react';

export default function Calculator() {
  useEffect(() => {
    // component logic here
  }, []);
  return (
    <>
      {/* UI elements */}
    </>
  );
}

Edge Function (Supabase)

// supabase/functions/analyze-scenario/index.ts
import { serve } from "https://deno.land/std@0.168.0/http/server.ts";

serve(async (req) => {
  // This runs on the Edge, close to the user
  // Log anonymous stats
  const result = { /* analysis result */ };
  return new Response(JSON.stringify(result), {
    headers: { "Content-Type": "application/json" },
  });
});

The Bugs That Almost Killed Me

Bug #1: The Floating‑Point Nightmare

JavaScript’s native floating‑point arithmetic introduced subtle errors in interest calculations.

The Fix: Migrate all math to Decimal.js.

// ❌ BAD (Native JS)
const monthlyPayment = principal * rate / 12;

// ✅ GOOD (Decimal.js)
import Decimal from "decimal.js";

const monthlyPayment = new Decimal(principal)
  .mul(rate)
  .div(12);

The Results (Data from 2,000+ Users)

A quick look at the database shows how users are choosing strategies:

SELECT 
  strategy,
  COUNT(*) AS users,
  AVG(savings) AS avg_savings
FROM user_choices
GROUP BY strategy;
StrategyUsers (%)Avg Savings
Velocity Banking42%$142k
Extra Payments38%$89k
Investing Difference20%

When people see the math visualized, they rarely choose to “do nothing”.

Lessons Learned

  • Visualization Sells: A table of numbers is boring. A chart showing the “Freedom Date” moving from 2055 to 2032 is emotional.
  • Context Matters: The calculator alone wasn’t enough. Users needed to understand why the math works, so I linked the tool back to my Velocity Banking Strategy Guide to close the knowledge gap.

Try It Yourself

Discussion

Let me know your thoughts in the comments! 👇

Back to Blog

Related posts

Read more »

Rapg: TUI-based Secret Manager

We've all been there. You join a new project, and the first thing you hear is: > 'Check the pinned message in Slack for the .env file.' Or you have several .env...

Technology is an Enabler, not a Saviour

Why clarity of thinking matters more than the tools you use Technology is often treated as a magic switch—flip it on, and everything improves. New software, pl...