<?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: Mark</title>
    <description>The latest articles on DEV Community by Mark (@utlkit).</description>
    <link>https://dev.to/utlkit</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3952583%2Fdd419f16-895a-44a8-8467-f24f0d7ee62e.png</url>
      <title>DEV Community: Mark</title>
      <link>https://dev.to/utlkit</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/utlkit"/>
    <language>en</language>
    <item>
      <title>Cloudflare Pages Blank Page? The index.txt Trap with Next.js Static Export</title>
      <dc:creator>Mark</dc:creator>
      <pubDate>Sun, 21 Jun 2026 14:27:31 +0000</pubDate>
      <link>https://dev.to/utlkit/cloudflare-pages-blank-page-the-indextxt-trap-with-nextjs-static-export-3g7n</link>
      <guid>https://dev.to/utlkit/cloudflare-pages-blank-page-the-indextxt-trap-with-nextjs-static-export-3g7n</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;After deployment, the site occasionally showed a blank screen on the homepage — refreshing fixed it.&lt;br&gt;
Debugging this took half a day. The culprit was a subtle interaction between Next.js and Cloudflare.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;After deploying to Cloudflare Pages, most visits work fine. But occasionally — especially when navigating to the homepage from another page — a blank screen appears. Refresh and it's fine.&lt;/p&gt;

&lt;p&gt;Sentry reports no errors. The Network tab looks fine — at first glance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging Process
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Check Cloudflare Cache
&lt;/h3&gt;

&lt;p&gt;First instinct: Cloudflare cached an intermediate state. Cleared cache. Problem persisted.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Browser DevTools
&lt;/h3&gt;

&lt;p&gt;Opened Network tab, enabled "Preserve log", reproduced the issue.&lt;/p&gt;

&lt;p&gt;When the blank screen appeared, the &lt;code&gt;/&lt;/code&gt; request had &lt;code&gt;Content-Type: text/plain&lt;/code&gt; in the response headers, with an empty body.&lt;/p&gt;

&lt;p&gt;Normally it should be &lt;code&gt;Content-Type: text/html&lt;/code&gt; with &lt;code&gt;index.html&lt;/code&gt; content.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: Content Negotiation
&lt;/h3&gt;

&lt;p&gt;Why does the same URL sometimes return HTML and sometimes text/plain?&lt;/p&gt;

&lt;p&gt;Key clue: Before navigating to &lt;code&gt;/&lt;/code&gt;, the browser sends a &lt;strong&gt;prefetch request&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="nf"&gt;GET&lt;/span&gt; &lt;span class="nn"&gt;/&lt;/span&gt; &lt;span class="k"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="m"&gt;1.1&lt;/span&gt;
&lt;span class="na"&gt;Accept&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;text/plain&lt;/span&gt;
&lt;span class="na"&gt;Accept-Encoding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;gzip, deflate, br&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This prefetch with &lt;code&gt;Accept: text/plain&lt;/code&gt; is from Next.js 15's &lt;strong&gt;content negotiation prefetch&lt;/strong&gt; mechanism.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root Cause Analysis
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Next.js 15 Prefetch Behavior
&lt;/h3&gt;

&lt;p&gt;Before client-side navigation, Next.js 15 prefetches the target resource. For efficiency, it sometimes requests with &lt;code&gt;Accept: text/plain&lt;/code&gt; — expecting lightweight metadata instead of full HTML.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next.js Static Export Creates index.txt
&lt;/h3&gt;

&lt;p&gt;During &lt;code&gt;output: 'export'&lt;/code&gt; build, Next.js creates &lt;code&gt;out/index.html&lt;/code&gt; for the &lt;code&gt;/&lt;/code&gt; route. But internal processes (content negotiation support) also generate &lt;code&gt;out/index.txt&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cloudflare Pages File Matching
&lt;/h3&gt;

&lt;p&gt;Cloudflare Pages static hosting routing rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;GET /&lt;/code&gt; + &lt;code&gt;Accept: text/html&lt;/code&gt; → matches &lt;code&gt;index.html&lt;/code&gt; ✅&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;GET /&lt;/code&gt; + &lt;code&gt;Accept: text/plain&lt;/code&gt; → matches &lt;code&gt;index.txt&lt;/code&gt; ✅ (if it exists)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When &lt;code&gt;index.txt&lt;/code&gt; exists, Cloudflare Pages does content negotiation based on the &lt;code&gt;Accept&lt;/code&gt; header and returns &lt;code&gt;index.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;index.txt&lt;/code&gt; is empty, users see a blank page.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Complete Bug Chain
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App Router Link prefetch
  → browser sends GET / Accept: text/plain
    → Cloudflare Pages finds index.txt
      → returns empty text/plain response
        → browser uses this as page content
          → Blank screen!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Evolution: From Blank Screen to 404 Flood
&lt;/h2&gt;

&lt;p&gt;The delete approach fixed the blank screen, but introduced a new problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem
&lt;/h3&gt;

&lt;p&gt;With 150+ tool pages, each page triggers an &lt;code&gt;Accept: text/plain&lt;/code&gt; prefetch request during client-side navigation. With &lt;code&gt;index.txt&lt;/code&gt; deleted, every request returns 404.&lt;/p&gt;

&lt;p&gt;F12 Network panel is filled with 404s:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/              404 (text/plain)
/tools/json-formatter/  404 (text/plain)
/tools/base64/          404 (text/plain)
/tools/uuid-generator/  404 (text/plain)
...                  (100+)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Impact
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Visual noise&lt;/strong&gt;: Network panel full of red 404s during debugging&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Wasted bandwidth&lt;/strong&gt;: Each 404 costs a Cloudflare request and response&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Connection contention&lt;/strong&gt;: HTTP/1.1 has 6 concurrent connections per domain; 404s steal slots from real resources&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cloudflare doesn't cache 404s&lt;/strong&gt;: Every visit hits the origin&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Better Approach: Create Empty index.txt
&lt;/h3&gt;

&lt;p&gt;Instead of deleting, create them — let the prefetch hit a valid 200 response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// scripts/create-index-txt.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fs&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;path&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createIndexTxtFiles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;count&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
  &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentDir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;indexPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentDir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;indexPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;txtPath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentDir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;index.txt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;txtPath&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;writeFileSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;txtPath&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;entries&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentDir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;withFileTypes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="nx"&gt;entries&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isDirectory&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;currentDir&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;entry&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&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;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&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="nf"&gt;walk&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;dir&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Created &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt; index.txt files`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;createIndexTxtFiles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;__dirname&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;..&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update build script:&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="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"scripts"&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;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"next build &amp;amp;&amp;amp; node scripts/create-index-txt.js"&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;h3&gt;
  
  
  Why Creating Is Better Than Deleting
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;Delete index.txt&lt;/th&gt;
&lt;th&gt;Create empty index.txt&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Prefetch result&lt;/td&gt;
&lt;td&gt;404&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;200 OK (0 bytes)&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cloudflare cache&lt;/td&gt;
&lt;td&gt;❌ Doesn't cache 404&lt;/td&gt;
&lt;td&gt;✅ Caches 200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Connection contention&lt;/td&gt;
&lt;td&gt;Every request hits origin&lt;/td&gt;
&lt;td&gt;Cache HIT, instant return&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Network panel&lt;/td&gt;
&lt;td&gt;Full of red&lt;/td&gt;
&lt;td&gt;All green&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Blank screen risk&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;td&gt;None (empty file won't override HTML)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;File size&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;0 bytes × page count&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Key insight: &lt;strong&gt;empty &lt;code&gt;index.txt&lt;/code&gt; won't cause a blank screen&lt;/strong&gt;. When Next.js client receives empty content, it knows this isn't valid HTML and automatically falls back to requesting the full &lt;code&gt;index.html&lt;/code&gt; with &lt;code&gt;Accept: text/html&lt;/code&gt;. Once Cloudflare caches this 200 response, subsequent prefetches are cache HITs — no wasted connections.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Read your hosting platform's file matching docs&lt;/strong&gt; — Cloudflare Pages' content negotiation differs from standard static servers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Browser prefetches are a double-edged sword&lt;/strong&gt; — They optimize load time but add edge cases&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inspect the build output directory&lt;/strong&gt; — &lt;code&gt;ls -la out/&lt;/code&gt; to check for unexpected files&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Blank page → check Network first&lt;/strong&gt; — Wrong Content-Type is often the root cause&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't fight the platform&lt;/strong&gt; — Instead of deleting files and flooding with 404s, work with the mechanism&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Project
&lt;/h2&gt;

&lt;p&gt;Full build config and deployment flow at &lt;a href="https://utlkit.com" rel="noopener noreferrer"&gt;UtlKit&lt;/a&gt; — 150+ free online tools, Next.js 15 static export + Cloudflare Pages zero-cost deployment.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If this helped, leave a ❤️.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>tailwindcss</category>
      <category>typescript</category>
    </item>
    <item>
      <title>React 19 Hydration Mismatch in Static Export</title>
      <dc:creator>Mark</dc:creator>
      <pubDate>Sun, 14 Jun 2026 14:18:22 +0000</pubDate>
      <link>https://dev.to/utlkit/react-19-hydration-mismatch-in-static-export-4kpn</link>
      <guid>https://dev.to/utlkit/react-19-hydration-mismatch-in-static-export-4kpn</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;📚 &lt;strong&gt;This is Part 3 of the UtlKit Tech Series&lt;/strong&gt; — &lt;br&gt;
Part 2 covers the architecture &amp;amp; trade-offs → &lt;a href="https://dev.to/utlkit/150-tools-with-only-2-layout-components-utlkit-architecture-design-35j4"&gt;Read Part 2&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  React 19 Static Export Hydration Mismatch? Pitfalls in Next.js 15
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;I built a 150+-tool online site with Next.js 15, deployed on Cloudflare Pages.&lt;br&gt;
Everything looked great until the console started flooding with Hydration Error #418.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Open DevTools Console — a wall of red:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: Hydration failed because the server rendered HTML didn't match the client.
Expected server HTML: &amp;lt;html class="dark"&amp;gt;
Client-rendered HTML: &amp;lt;html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The site works fine functionally, but this error hurts SEO scores and floods Sentry.&lt;/p&gt;

&lt;p&gt;Weirder still: &lt;code&gt;npm run dev&lt;/code&gt; works fine. &lt;code&gt;npm run build &amp;amp;&amp;amp; npm start&lt;/code&gt; breaks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Root Cause Analysis
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Layer 1: React 19 RSC and Static Export Compatibility
&lt;/h3&gt;

&lt;p&gt;Next.js 15 defaults to React 19 with React Server Components (RSC). But in &lt;code&gt;output: 'export'&lt;/code&gt; mode, every page is statically rendered to HTML.&lt;/p&gt;

&lt;p&gt;The problem:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;SSR phase&lt;/strong&gt;: Server-side render tries to read localStorage (theme value) → can't read it (no localStorage on server)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSR phase&lt;/strong&gt;: Client-side hydration reads localStorage → has a value, dynamically adds &lt;code&gt;class="dark"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Result&lt;/strong&gt;: SSR HTML ≠ CSR HTML → Hydration Mismatch&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Layer 2: Dynamic className on &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;layout.tsx&lt;/code&gt; had code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ❌ Causes Hydration Mismatch&lt;/span&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;RootLayout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useTheme&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="c1"&gt;// Client hook reading localStorage&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;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"zh"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;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;code&gt;useTheme()&lt;/code&gt; returns the default value (&lt;code&gt;light&lt;/code&gt;) during SSR, but returns the localStorage value (possibly &lt;code&gt;dark&lt;/code&gt;) during CSR. Different class on &lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; → Hydration Error.&lt;/p&gt;

&lt;h3&gt;
  
  
  Layer 3: Terser Made Things Worse
&lt;/h3&gt;

&lt;p&gt;To reduce bundle size, I added Terser minification to the build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// next.config.js&lt;/span&gt;
&lt;span class="nx"&gt;compress&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Terser compression, code execution timing changed subtly, making hydration behave inconsistently across browsers (especially Chrome). Sometimes it hydrates fine, sometimes it errors — non-deterministic bugs are the worst.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solutions (Progressive)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Solution 1: suppressHydrationWarning (Quick Fix)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// ✅ Tells React to ignore differences on &amp;lt;html&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"zh"&lt;/span&gt; &lt;span class="na"&gt;className&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;suppressHydrationWarning&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; Errors gone ✅&lt;br&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; This masks the issue. Dark mode still flashes on first paint — white then black.&lt;/p&gt;
&lt;h3&gt;
  
  
  Solution 2: Head Script to Pre-read Theme (Eliminates Flash)
&lt;/h3&gt;

&lt;p&gt;Add a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; that executes before React renders:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;theme&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;light&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;documentElement&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;style&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;colorScheme&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;theme&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;})();&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result:&lt;/strong&gt; No first-paint flash ✅, suppressHydrationWarning clears errors ✅&lt;br&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; Good enough, but I wanted to try React 19...&lt;/p&gt;
&lt;h3&gt;
  
  
  Solution 3: Downgrade React 19 → 18 (Root Fix)
&lt;/h3&gt;

&lt;p&gt;After testing, React 19's RSC has several known issues with &lt;code&gt;output: 'export'&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different hydration timing than React 18&lt;/li&gt;
&lt;li&gt;Some Server Component features behave unexpectedly during static export&lt;/li&gt;
&lt;li&gt;Many community reports (GitHub Issues)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Downgraded decisively:&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;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;package.json&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;"dependencies"&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;"react"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.3.1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"react-dom"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"^18.3.1"&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;Result:&lt;/strong&gt; All Hydration issues completely resolved ✅&lt;br&gt;
&lt;strong&gt;Problem:&lt;/strong&gt; Lost RSC, but static sites don't need it anyway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Final Solution (What's in Production)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// app/layout.tsx&lt;/span&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;RootLayout&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;children&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="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"zh"&lt;/span&gt; &lt;span class="na"&gt;suppressHydrationWarning&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;head&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt; &lt;span class="na"&gt;dangerouslySetInnerHTML&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;__html&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;`
          (function() {
            try {
              var t = localStorage.getItem('theme') || 'light';
              document.documentElement.classList.add(t);
              document.documentElement.style.colorScheme = t;
            } catch(e) {}
          })();
        `&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;head&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;body&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;html&lt;/span&gt;&lt;span class="p"&gt;&amp;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;Key points:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; in &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; executes before React → eliminates flash&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;suppressHydrationWarning&lt;/code&gt; → eliminates errors&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;try/catch&lt;/code&gt; → prevents localStorage errors in restricted environments (iframes, etc.)&lt;/li&gt;
&lt;li&gt;React 18 → stable hydration timing&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Approach&lt;/th&gt;
&lt;th&gt;Effect&lt;/th&gt;
&lt;th&gt;Recommendation&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;suppressHydrationWarning&lt;/code&gt; only&lt;/td&gt;
&lt;td&gt;Clears errors, but flash remains&lt;/td&gt;
&lt;td&gt;⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Head script + &lt;code&gt;suppressHydrationWarning&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;No errors, no flash&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;React 19→18 downgrade + head script&lt;/td&gt;
&lt;td&gt;Most stable&lt;/td&gt;
&lt;td&gt;⭐⭐⭐⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;useLayoutEffect&lt;/code&gt; delayed DOM&lt;/td&gt;
&lt;td&gt;Works but complex&lt;/td&gt;
&lt;td&gt;⭐⭐⭐&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Core takeaways:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Static sites don't need RSC&lt;/strong&gt; — RSC brings 10x more problems than benefits in &lt;code&gt;output: 'export'&lt;/code&gt; mode&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;localStorage is the #1 cause of Hydration mismatches&lt;/strong&gt; — SSR can't read it, CSR can, guaranteed inconsistency&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Head script is the best pattern for theme/locale flash&lt;/strong&gt; — Zero dependencies, zero overhead&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't over-optimize builds&lt;/strong&gt; — Terser saved a few KB but introduced non-deterministic bugs&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Project
&lt;/h2&gt;

&lt;p&gt;This site is &lt;a href="https://utlkit.com" rel="noopener noreferrer"&gt;UtlKit&lt;/a&gt; — 150+ free online developer tools. All the issues above were encountered during real development and deployment, and the solutions are running stably in production.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;If this helped, feel free to leave a ❤️. Questions welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>typescript</category>
      <category>tailwindcss</category>
    </item>
    <item>
      <title>150+ Tools with Only 2 Layout Components: UtlKit Architecture Design</title>
      <dc:creator>Mark</dc:creator>
      <pubDate>Sat, 06 Jun 2026 06:56:26 +0000</pubDate>
      <link>https://dev.to/utlkit/150-tools-with-only-2-layout-components-utlkit-architecture-design-35j4</link>
      <guid>https://dev.to/utlkit/150-tools-with-only-2-layout-components-utlkit-architecture-design-35j4</guid>
      <description>&lt;h2&gt;
  
  
  150+ Tools with Only 2 Layout Components: UtlKit Architecture Design
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;UtlKit Series Part 2/2: Architecture and Trade-offs&lt;br&gt;
Part 1 covers the story and tech choices → &lt;a href="https://dev.to/utlkit/i-spent-2-months-building-a-150-tool-website-with-0-server-cost-4lem"&gt;Read Part 1&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;150+ tools, but only 2 core layouts. Good architecture doubles development speed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Overall Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9monbvt49ypq5m5oj4d0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9monbvt49ypq5m5oj4d0.png" alt="Overall Architecture" width="799" height="662"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Directory Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/
├── app/
│   ├── layout.tsx          # Root layout: Sentry, fonts, theme
│   ├── page.tsx            # Homepage: category tabs + tool grid
│   ├── page.client.tsx     # Homepage client-side logic
│   ├── tools/
│   │   ├── json-formatter/
│   │   │   ├── page.tsx    # Page + SEO metadata
│   │   │   └── formatter.tsx # Tool core logic
│   │   ├── hash-generator/
│   │   ├── base64/
│   │   └── ... (150+ tools total)
│   ├── about/page.tsx
│   ├── contact/page.tsx
│   ├── privacy/page.tsx
│   └── terms/page.tsx
├── components/
│   ├── ConverterLayout.tsx  # Shared layout for converter tools
│   ├── ToolSection.tsx      # Shared layout for calculator tools
│   ├── Header.tsx           # Nav + search + language + theme toggle
│   ├── Footer.tsx
│   ├── Breadcrumbs.tsx
│   ├── ThemeProvider.tsx
│   └── AdSlot.tsx
├── lib/
│   ├── tools.ts             # Tool metadata (150+ tools: name/icon/category)
│   ├── i18n/
│   │   ├── en.ts            # English ~2200 lines
│   │   └── zh-CN.ts         # Chinese ~2200 lines
│   ├── md5.ts               # Pure JS MD5 implementation
│   ├── sentry-release.ts
│   └── tool-seo.ts
└── styles/
    └── globals.css          # Tailwind + CSS custom properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Component Abstraction: 80% of Tools Share Layouts
&lt;/h2&gt;

&lt;p&gt;150+ tools distilled into two core layouts:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. ConverterLayout — Input → Process → Output
&lt;/h3&gt;

&lt;p&gt;JSON formatter, Base64, Hash, and similar tools all use this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────┐
│  Input          │  Output       │
│  textarea       │  textarea     │
│                 │               │
│  [Convert]      │  [Copy]       │
└─────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. ToolSection — Form → Calculate → Result
&lt;/h3&gt;

&lt;p&gt;BMI, Compound Interest, Loan calculator and similar:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌────────────────────────┐
│  [Input 1]             │
│  [Input 2]             │
│  [Input 3]             │
│                        │
│  [Calculate]           │
│                        │
│  ─── Result ───        │
│  Result display area   │
└────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These two shared layouts + minimal custom logic per tool dramatically improved development efficiency. Each tool only needs to implement its core conversion logic — the UI is handled uniformly by the layout components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Browser-Only Trade-offs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Biggest Trade-off: No Node.js Ecosystem
&lt;/h3&gt;

&lt;p&gt;Node.js has mature formatting/minification libraries, but the browser doesn't have &lt;code&gt;fs&lt;/code&gt;, &lt;code&gt;net&lt;/code&gt;, or &lt;code&gt;child_process&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Library&lt;/th&gt;
&lt;th&gt;Node.js Dependency&lt;/th&gt;
&lt;th&gt;Alternative&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;terser&lt;/code&gt; (JS minification)&lt;/td&gt;
&lt;td&gt;✅ &lt;code&gt;fs&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Custom regex minifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;html-minifier-terser&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;✅ &lt;code&gt;fs&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Custom regex minifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;xml-formatter&lt;/code&gt; minify&lt;/td&gt;
&lt;td&gt;⚠️ ESM/CJS issues&lt;/td&gt;
&lt;td&gt;Custom regex minifier&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;js-beautify&lt;/code&gt; (formatting)&lt;/td&gt;
&lt;td&gt;❌ Browser-compatible&lt;/td&gt;
&lt;td&gt;✅ Use directly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;csso&lt;/code&gt; (CSS minification)&lt;/td&gt;
&lt;td&gt;❌ Pure JS&lt;/td&gt;
&lt;td&gt;✅ Use directly&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Conclusion: Use existing libraries for formatting, write custom regex for minification.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Full analysis in Part 3 → Why Node.js Libraries Don't Work in the Browser&lt;/p&gt;

&lt;h3&gt;
  
  
  Encryption: Web Crypto API Limitations
&lt;/h3&gt;

&lt;p&gt;The browser natively supports SHA-256/384/512, AES-GCM, and HMAC — but &lt;strong&gt;not MD5&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;MD5 is proven insecure, but it's still widely used in practice (file checksums, legacy system compatibility, etc.).&lt;/p&gt;

&lt;p&gt;Solution: Implement MD5 yourself (~100 lines of pure JS, bitwise operations).&lt;/p&gt;

&lt;p&gt;Full analysis in Part 5 → Client-Side Encryption with Web Crypto API&lt;/p&gt;

&lt;h2&gt;
  
  
  i18n: Bilingual Design
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/lib/i18n/
├── en.ts       (2208 lines)
└── zh-CN.ts    (2207 lines)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Usage:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;t&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useI18n&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;button&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;t&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;btn.copy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&amp;lt;&lt;/span&gt;&lt;span class="err"&gt;/&lt;/span&gt;&lt;span class="na"&gt;button&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;  // "Copy" / "复制"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key decisions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Not using &lt;code&gt;next-intl&lt;/code&gt;&lt;/strong&gt; — SSR safety issues in static export mode&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;localStorage&lt;/code&gt; + Context&lt;/strong&gt; — Simple and controllable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;All page titles bilingual&lt;/strong&gt; — SEO-friendly for both languages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool names also bilingual&lt;/strong&gt; — Search, breadcrumbs, sitemap&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  From 0 to 1 to 100
&lt;/h2&gt;

&lt;p&gt;These two articles cover the "0 to 1" — design decisions and architecture. The following articles cover the "1 to 100" — real-world pitfalls:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;th&gt;Core Problem&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;React 19 Hydration Mismatch in Static Export&lt;/td&gt;
&lt;td&gt;SSR/CSR inconsistency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Cloudflare Pages Blank Page: the index.txt Bug&lt;/td&gt;
&lt;td&gt;Content negotiation mechanism&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Why Node.js Libraries Fail in the Browser&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;fs&lt;/code&gt; dependencies, ESM/CJS interop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Sentry Source Maps: From 0% to Full Resolution&lt;/td&gt;
&lt;td&gt;Tree-shaking, HTTP API, region detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Client-Side Encryption with Web Crypto API&lt;/td&gt;
&lt;td&gt;MD5 gap, AES-GCM, HMAC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Free Performance Monitoring: PageSpeed CI&lt;/td&gt;
&lt;td&gt;Zero-cost Core Web Vitals monitoring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Cloudflare Cache Hit Rate: 7% → 90%&lt;/td&gt;
&lt;td&gt;3 Cache Rules + localization optimization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Perfect Dark Mode: From Hydration Error to Zero Flicker&lt;/td&gt;
&lt;td&gt;Troubleshooting 8 pitfalls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;6 Pitfalls of Multilingual Sites&lt;/td&gt;
&lt;td&gt;query string → path prefix, 3 rounds of redesign&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Project Info
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://utlkit.com" rel="noopener noreferrer"&gt;utlkit.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stack:&lt;/strong&gt; Next.js 15 + React 18 + TypeScript + Tailwind CSS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting:&lt;/strong&gt; Cloudflare Pages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; 150+ tools, 8 categories&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; $0/month&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;If you find this helpful, follow along for the rest of the series. Constructive feedback welcome in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>tailwindcss</category>
      <category>react</category>
      <category>typescript</category>
    </item>
    <item>
      <title>I Spent 2 Months Building a 150+ Tool Website with $0 Server Cost</title>
      <dc:creator>Mark</dc:creator>
      <pubDate>Mon, 01 Jun 2026 12:57:55 +0000</pubDate>
      <link>https://dev.to/utlkit/i-spent-2-months-building-a-150-tool-website-with-0-server-cost-4lem</link>
      <guid>https://dev.to/utlkit/i-spent-2-months-building-a-150-tool-website-with-0-server-cost-4lem</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;📚 &lt;strong&gt;This is Part 1 (Opening) of the UtlKit Tech Series&lt;/strong&gt; — &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Next: &lt;a href="https://dev.to/utlkit/150-tools-with-only-2-layout-components-utlkit-architecture-design-35j4"&gt;Architecture &amp;amp; Trade-offs →&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;




&lt;p&gt;As a frontend developer, I've used countless online tools. And almost all of them suck:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sign-up required&lt;/strong&gt; — just to format a JSON string?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ad overload&lt;/strong&gt; — the actual tool gets squeezed into a corner&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Privacy concerns&lt;/strong&gt; — your JSON might contain API keys, and the tool sends it to a server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Fragmented&lt;/strong&gt; — formatters on one site, Base64 on another, hashing on a third&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So I decided to build one that doesn't: no sign-up, no ads, pure client-side computation, data never leaves the browser.&lt;/p&gt;

&lt;p&gt;The goal was simple — &lt;strong&gt;if I need this tool, someone else does too.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The result is &lt;a href="https://utlkit.com" rel="noopener noreferrer"&gt;utlkit.com&lt;/a&gt;: 150+ tools, 8 categories, zero server costs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Requirements
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Requirement&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Pure client-side&lt;/td&gt;
&lt;td&gt;All logic runs in the browser&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Zero server cost&lt;/td&gt;
&lt;td&gt;Static hosting, no Node.js backend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;150+ pages&lt;/td&gt;
&lt;td&gt;One page per tool, SEO-friendly&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Bilingual (EN/ZH)&lt;/td&gt;
&lt;td&gt;i18n support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Dark/Light mode&lt;/td&gt;
&lt;td&gt;User preference&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mobile responsive&lt;/td&gt;
&lt;td&gt;Works on all devices&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  Why Not Other Frameworks?
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Option&lt;/th&gt;
&lt;th&gt;Pros&lt;/th&gt;
&lt;th&gt;Cons&lt;/th&gt;
&lt;th&gt;Verdict&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Vanilla HTML/JS&lt;/td&gt;
&lt;td&gt;Simple&lt;/td&gt;
&lt;td&gt;Managing 150+ pages is painful&lt;/td&gt;
&lt;td&gt;Too slow&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;VuePress / VitePress&lt;/td&gt;
&lt;td&gt;Fast&lt;/td&gt;
&lt;td&gt;Docs-oriented, not for interactive tools&lt;/td&gt;
&lt;td&gt;Not flexible enough&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nuxt SSR&lt;/td&gt;
&lt;td&gt;Powerful&lt;/td&gt;
&lt;td&gt;Needs a server&lt;/td&gt;
&lt;td&gt;Violates zero-cost principle&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Next.js 15 + &lt;code&gt;output: 'export'&lt;/code&gt;&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;SSR SEO + client interactivity + static hosting&lt;/td&gt;
&lt;td&gt;Has pitfalls (covered later)&lt;/td&gt;
&lt;td&gt;✅ Best balance&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  The Key Decision: &lt;code&gt;output: 'export'&lt;/code&gt;
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// next.config.js&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;nextConfig&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;output&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;export&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;       &lt;span class="c1"&gt;// Static export&lt;/span&gt;
  &lt;span class="na"&gt;trailingSlash&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;    &lt;span class="c1"&gt;// Required for static files&lt;/span&gt;
  &lt;span class="na"&gt;images&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;unoptimized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="c1"&gt;// No image optimization server&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;ul&gt;
&lt;li&gt;✅ Build output is plain HTML/CSS/JS files&lt;/li&gt;
&lt;li&gt;✅ Deployable to any static host (Cloudflare Pages, Vercel, GitHub Pages)&lt;/li&gt;
&lt;li&gt;✅ Zero server cost&lt;/li&gt;
&lt;li&gt;❌ No API Routes, no Server Components, limited dynamic routing&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Deployment: Zero Cost on Cloudflare Pages
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;Build output&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;out/ directory, ~14 MB&lt;/span&gt;
&lt;span class="na"&gt;Hosting&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Cloudflare Pages&lt;/span&gt;
&lt;span class="na"&gt;Domain&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;utlkit.com&lt;/span&gt;
&lt;span class="na"&gt;Monthly cost&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;$0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Build Pipeline
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run build
  → next build &lt;span class="o"&gt;(&lt;/span&gt;output: &lt;span class="s1"&gt;'export'&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
  → Generates out/ directory
  → clean-index-txt.js &lt;span class="o"&gt;(&lt;/span&gt;removes index.txt&lt;span class="o"&gt;)&lt;/span&gt;
  → Outputs 150+ static HTML files
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Cloudflare Pages CI/CD: git push → auto build → auto deploy, ~3 minutes to production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's Coming Next in This Series
&lt;/h2&gt;

&lt;p&gt;Above is the story and the tech choices. The following articles cover real-world pitfalls:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Part&lt;/th&gt;
&lt;th&gt;Title&lt;/th&gt;
&lt;th&gt;Core Problem&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;Architecture and Trade-offs&lt;/td&gt;
&lt;td&gt;Structure, reusability &amp;amp; trade-offs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;React 19 Hydration Mismatch in Static Export&lt;/td&gt;
&lt;td&gt;SSR/CSR inconsistency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Cloudflare Pages Blank Page: the index.txt Bug&lt;/td&gt;
&lt;td&gt;Content negotiation mechanism&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Why Node.js Libraries Fail in the Browser&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;fs&lt;/code&gt; dependencies, ESM/CJS interop&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;Sentry Source Maps: From 0% to Full Resolution&lt;/td&gt;
&lt;td&gt;Tree-shaking, HTTP API, region detection&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;Client-Side Encryption with Web Crypto API&lt;/td&gt;
&lt;td&gt;MD5 gap, AES-GCM, HMAC&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;Free Performance Monitoring: PageSpeed CI&lt;/td&gt;
&lt;td&gt;Zero-cost Core Web Vitals monitoring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;Cloudflare Cache Hit Rate: 7% → 90%&lt;/td&gt;
&lt;td&gt;3 Cache Rules + localization optimization&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;Perfect Dark Mode: From Hydration Error to Zero Flicker&lt;/td&gt;
&lt;td&gt;Troubleshooting 8 pitfalls&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;6 Pitfalls of Multilingual Sites&lt;/td&gt;
&lt;td&gt;query string → path prefix, 3 rounds of redesign&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Each article includes full debugging process, code examples, and lessons learned.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;📚 &lt;strong&gt;This is Part 1 (Opening) of the UtlKit Tech Series&lt;/strong&gt; — &amp;gt; - Next: &lt;a href="https://dev.to/utlkit/150-tools-with-only-2-layout-components-utlkit-architecture-design-35j4"&gt;Architecture &amp;amp; Trade-offs →&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Project Info
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Website:&lt;/strong&gt; &lt;a href="https://utlkit.com" rel="noopener noreferrer"&gt;utlkit.com&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Stack:&lt;/strong&gt; Next.js 15 + React 18 + TypeScript + Tailwind CSS&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting:&lt;/strong&gt; Cloudflare Pages&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; 150+ tools, 8 categories&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; $0/month&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;Part 2 will cover architecture design: directory structure, component abstraction, browser-only trade-offs, and i18n approach. Follow along for the full series.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>typescript</category>
      <category>tailwindcss</category>
    </item>
  </channel>
</rss>
