<?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: jerehere</title>
    <description>The latest articles on DEV Community by jerehere (@jerehere).</description>
    <link>https://dev.to/jerehere</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3858030%2F71d6d135-9cff-474d-9b84-61c847fe008b.png</url>
      <title>DEV Community: jerehere</title>
      <link>https://dev.to/jerehere</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jerehere"/>
    <language>en</language>
    <item>
      <title>How I Statically Generated 18,673 Pages with Next.js (and What Broke Along the Way)</title>
      <dc:creator>jerehere</dc:creator>
      <pubDate>Thu, 02 Apr 2026 19:11:16 +0000</pubDate>
      <link>https://dev.to/jerehere/how-i-statically-generated-18673-pages-with-nextjs-and-what-broke-along-the-way-58am</link>
      <guid>https://dev.to/jerehere/how-i-statically-generated-18673-pages-with-nextjs-and-what-broke-along-the-way-58am</guid>
      <description>&lt;p&gt;I recently shipped CalcFi — a site with 160+ financial calculators, each with a 2,000+ word guide, FAQs, and charts. The whole thing is statically generated on Vercel's free tier.&lt;/p&gt;

&lt;p&gt;18,673 pages. Zero API calls at runtime. Sub-100ms TTFB.&lt;/p&gt;

&lt;p&gt;Here's what I learned building it.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;The Architecture&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Next.js 16 + App Router
├── 160 calculator directories
│   ├── page.tsx (server component — metadata, JSON-LD, article)
│   └── calc.tsx (client component — calculator UI, state, math)
├── 50 state tax pages (×3 variants each)
├── Category hubs, guides, glossary
└── Static generation for everything
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every calculator follows the same pattern: a server component handles SEO (metadata, structured data, the 2,000-word guide), and a client component handles the interactive calculator. The math never leaves the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Worked&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Two-File Pattern&lt;/strong&gt;&lt;br&gt;
Splitting each calculator into page.tsx (server) and calc.tsx (client) was the best architectural decision. The server component renders all the content Google needs to index — no hydration required for the article, FAQs, or structured data. The client component is only the interactive calculator.&lt;/p&gt;

&lt;p&gt;This means Google sees a fully-rendered page with 2,000+ words of content on first crawl, even with JS disabled.&lt;/p&gt;

&lt;p&gt;**2. Static Generation at Scale&lt;br&gt;
**Next.js generateStaticParams handles the 18K pages surprisingly well. Build time: ~45 seconds. The trick is keeping each page's data requirements minimal — no database calls, no external APIs. Everything is computed from local data files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Each state × each calculator = thousands of pages&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;generateStaticParams&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;states&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;flatMap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;state&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt;
    &lt;span class="nx"&gt;calculators&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;calc&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;calculator&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&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;&lt;strong&gt;3. Client-Side Math = Zero Server Costs&lt;/strong&gt;&lt;br&gt;
Every calculator runs entirely in the browser. No API routes, no serverless functions, no database. The formulas are in the client bundle. &lt;/p&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Vercel free tier handles everything&lt;/li&gt;
&lt;li&gt;No cold starts&lt;/li&gt;
&lt;li&gt;Works offline (once loaded)&lt;/li&gt;
&lt;li&gt;User data never leaves their browser (privacy win)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. JSON-LD on Everything&lt;/strong&gt;&lt;br&gt;
Every page has structured data — WebApplication for calculators, FAQPage for FAQ sections, BreadcrumbList for navigation. This is tedious but it's what gets you rich snippets in search results.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="err"&gt;const&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;jsonLd&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"@context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://schema.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"@type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"WebApplication"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Retirement Calculator"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://calcfi.app/calculators/retirement-calculator"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"applicationCategory"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"FinanceApplication"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"operatingSystem"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Any"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"offers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"@type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Offer"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What Broke&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Build Memory at 18K Pages&lt;/strong&gt;&lt;br&gt;
Around 15,000 pages, the build started hitting memory limits on Vercel's free tier. The fix was splitting generateStaticParams into chunks and using export const dynamicParams = true as a fallback for edge cases. Not elegant, but it works.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Sitemap Size Limits&lt;/strong&gt;&lt;br&gt;
A single sitemap file maxes out at 50,000 URLs (per the spec), but Google practically gets unhappy above ~10,000. I split into multiple sitemap files using Next.js's built-in sitemap.ts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sitemap&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nx"&gt;MetadataRoute&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Sitemap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;calculatorPages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;statePages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;guidePages&lt;/span&gt;&lt;span class="p"&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;At 18K pages this needed chunking into sitemap index + child sitemaps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. OG Images at Scale&lt;/strong&gt;&lt;br&gt;
Each calculator has a dynamic OG image via opengraph-image.tsx. With 160+ calculators, that's 160+ edge function invocations for social previews. I moved to a single parameterized OG route that takes the calculator slug and generates the image on-demand.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Component Consistency Across 160 Calculators&lt;/strong&gt;&lt;br&gt;
The first 20 calculators were hand-crafted. By calculator #40, I had three different button colors, two different result card patterns, and inconsistent input heights. The fix was extracting a CalculatorShell component that enforces consistency — JSON-LD, FAQs, related tools, disclaimers all come free when you wrap your calc in the shell.&lt;/p&gt;

&lt;p&gt;If I started over, I'd build CalculatorShell first and every calculator from day one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Numbers&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;18,673 static pages generated at build time&lt;/li&gt;
&lt;li&gt;Build time: ~45s on Vercel&lt;/li&gt;
&lt;li&gt;Lighthouse: 95+ performance across all pages&lt;/li&gt;
&lt;li&gt;Bundle per page: &amp;lt;120KB&lt;/li&gt;
&lt;li&gt;Monthly hosting cost: $0 (Vercel free tier)&lt;/li&gt;
&lt;li&gt;Total codebase: ~160 calculator modules, shared component library, data layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Key Takeaways&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Static generation scales further than you think. 18K pages on a free tier is wild. The constraint isn't page count — it's build memory and sitemap management.&lt;/p&gt;

&lt;p&gt;Server components + client components is the right split for tool sites. SEO content renders server-side, interactive bits render client-side. Best of both worlds.&lt;/p&gt;

&lt;p&gt;Build the shared component library first. I learned this the hard way. CalculatorShell should have been step 1, not step 40.&lt;/p&gt;

&lt;p&gt;JSON-LD is worth the tedium. Rich snippets in search are the difference between 2% and 8% CTR.&lt;/p&gt;

&lt;p&gt;Zero-runtime-cost architecture is underrated. No database, no API, no serverless = nothing to go down, nothing to pay for, nothing to scale.&lt;/p&gt;

&lt;p&gt;The site is &lt;a href="https://calcfi.app" rel="noopener noreferrer"&gt;CalcFi.app&lt;/a&gt; if you want to see the result. All 160+ calculators, no signup, no ads.&lt;/p&gt;

&lt;p&gt;Happy to answer questions about the architecture or Next.js static gen at scale.&lt;/p&gt;

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