<?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: AurinAilean</title>
    <description>The latest articles on DEV Community by AurinAilean (@aurinaileandot).</description>
    <link>https://dev.to/aurinaileandot</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%2F3967611%2F5e4853e5-9e45-4461-abab-8e0701766331.png</url>
      <title>DEV Community: AurinAilean</title>
      <link>https://dev.to/aurinaileandot</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aurinaileandot"/>
    <language>en</language>
    <item>
      <title>My Next.js 16 button was visible and completely dead in production. Here's why.</title>
      <dc:creator>AurinAilean</dc:creator>
      <pubDate>Fri, 05 Jun 2026 21:55:21 +0000</pubDate>
      <link>https://dev.to/aurinaileandot/my-nextjs-16-button-was-visible-and-completely-dead-in-production-heres-whyx-4k1b</link>
      <guid>https://dev.to/aurinaileandot/my-nextjs-16-button-was-visible-and-completely-dead-in-production-heres-whyx-4k1b</guid>
      <description>&lt;p&gt;I added a tiny test page to confirm my error monitoring was capturing frontend crashes. A title, a paragraph, one red button that throws an error on click. The kind of code you'd send to a code review and apologize for being trivial.&lt;/p&gt;

&lt;p&gt;Locally: worked perfectly. Click, error, captured, done.&lt;/p&gt;

&lt;p&gt;In production: the button rendered. Click did nothing. No error in the console. No network request. No visible feedback. Just dead HTML that looked exactly like a button.&lt;/p&gt;

&lt;p&gt;I'm a solo dev building an iOS market intelligence tool, and this bug burned an hour of my pre-launch sprint. The cause is a real Next.js 16 trap. The fix is well-documented. The path between "this should work" and "ah, it's this" is what I want to write about — because the same shape of bug is going to bite a lot of people once Next 16 spreads.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I had
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight tsx"&gt;&lt;code&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useSearchParams&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;next/navigation&lt;/span&gt;&lt;span class="dl"&gt;"&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;SentryTestPage&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;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSearchParams&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&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;key&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LockedScreen&lt;/span&gt; &lt;span class="p"&gt;/&amp;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;button&lt;/span&gt; &lt;span class="na"&gt;onClick&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test crash&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&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;
      Trigger crash
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&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;A page that reads a &lt;code&gt;?key=&lt;/code&gt; query param. If the key is missing, it shows a locked screen. If present, it shows the button. Trivial.&lt;/p&gt;

&lt;p&gt;In production with &lt;code&gt;?key=...&lt;/code&gt; in the URL, the button rendered. But nothing happened on click. No event, no error, no log. The button was a div pretending to be a button.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I tried first (and why each was wrong)
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Theory 1: The env variable isn't set.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I thought maybe &lt;code&gt;NEXT_PUBLIC_SENTRY_DSN&lt;/code&gt; wasn't actually present in the build. So Sentry never initialized, so when I threw an error there was no one to catch it. I checked Vercel. The variable was there. I re-deployed without build cache to make sure. Still dead.&lt;/p&gt;

&lt;p&gt;This was the right thing to check — &lt;code&gt;NEXT_PUBLIC_*&lt;/code&gt; vars are inlined at build time, and adding them later doesn't help unless you rebuild. But it wasn't the bug.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theory 2: A floating widget is overlaying the button.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The app has a feedback button fixed to the bottom-right corner. Z-index issues are a classic source of invisible click eaters. I inspected. The button received &lt;code&gt;pointer-events: auto&lt;/code&gt;. Nothing was on top. Not it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theory 3: The build is stale.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Hard-reload with &lt;code&gt;Cmd + Shift + R&lt;/code&gt;. Then incognito. The button still didn't respond. Not the cache.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Theory 4: React just isn't hydrating the page.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This was closer. If React fails to hydrate a subtree, the HTML is there but the JavaScript event handlers never attach. That'd look exactly like what I was seeing.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the actual bug is
&lt;/h2&gt;

&lt;p&gt;Next.js 16 (and 13+, but it's stricter in 16) requires that any component reading &lt;code&gt;useSearchParams()&lt;/code&gt; be wrapped in a &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt; boundary. Without it, here's what happens:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;During server-side rendering, &lt;code&gt;useSearchParams()&lt;/code&gt; returns an empty params object. The component renders the "no key" branch (&lt;code&gt;&amp;lt;LockedScreen /&amp;gt;&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;On the client, the URL has &lt;code&gt;?key=...&lt;/code&gt;, so &lt;code&gt;useSearchParams()&lt;/code&gt; returns the params, and the component wants to render the "button" branch.&lt;/li&gt;
&lt;li&gt;React tries to hydrate the server HTML and finds a mismatch: the server rendered &lt;code&gt;&amp;lt;LockedScreen /&amp;gt;&lt;/code&gt;, the client wants to render the button.&lt;/li&gt;
&lt;li&gt;React aborts hydration for that subtree. It logs a warning during development (if you're watching the console) but in production it just stops.&lt;/li&gt;
&lt;li&gt;The HTML the server sent — including whichever branch happened to be there — stays in the DOM. But no event handlers ever attach.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last point is the cruel part. In my case the &lt;em&gt;server&lt;/em&gt; had rendered the locked screen, but my browser then &lt;em&gt;swapped to the button&lt;/em&gt; in the DOM via... actually I'm not entirely sure how the button appeared at all, given the hydration was supposed to be aborted. I suspect a streaming SSR quirk where the client did render the button but React refused to wire it up. Either way: the button I saw was dead HTML.&lt;/p&gt;

&lt;p&gt;It worked locally because dev mode uses a different hydration strategy that is more forgiving of mismatches — it logs the warning and patches the DOM. Production mode does not.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix
&lt;/h2&gt;

&lt;p&gt;The documented Next.js 16 pattern is to put the &lt;code&gt;useSearchParams()&lt;/code&gt; call inside a child component, and wrap that child in &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt;:&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;use client&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Suspense&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useSearchParams&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;next/navigation&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;PageContent&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;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useSearchParams&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;key&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;key&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;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LockedScreen&lt;/span&gt; &lt;span class="p"&gt;/&amp;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;button&lt;/span&gt; &lt;span class="na"&gt;onClick&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;test crash&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&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;
      Trigger crash
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;button&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;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;SentryTestPage&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="nc"&gt;Suspense&lt;/span&gt; &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;null&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="nc"&gt;PageContent&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="nc"&gt;Suspense&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;Why this works: &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt; tells React that the wrapped content might not be ready during initial server render. The server emits the &lt;code&gt;fallback&lt;/code&gt; (&lt;code&gt;null&lt;/code&gt;), and the client renders the real content. Because the server doesn't commit to a branch, there's no mismatch to resolve. The client takes over cleanly, the button hydrates, the onClick attaches.&lt;/p&gt;

&lt;p&gt;After this fix the button worked on the first deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I should have done first
&lt;/h2&gt;

&lt;p&gt;The build log was actually telling me. Next.js prints a warning during production builds when a page uses &lt;code&gt;useSearchParams()&lt;/code&gt; without &lt;code&gt;&amp;lt;Suspense&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Entire page deopted into client-side rendering. Read more: ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I didn't see it because I was looking at runtime logs, not build logs. If I'd grep'd the build output for &lt;code&gt;deopted&lt;/code&gt;, I would have found this bug in 30 seconds instead of an hour.&lt;/p&gt;

&lt;p&gt;So the rule I'm internalizing:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When something works locally and breaks in production, read the build log first.&lt;/strong&gt; The framework probably already told you what's wrong. You're just not looking where it told you.&lt;/p&gt;

&lt;p&gt;A close second:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When a React event handler doesn't fire, suspect hydration before suspecting your code.&lt;/strong&gt; The button isn't broken — the path from rendered HTML to JavaScript-wired DOM is broken. Different debug target, different fix.&lt;/p&gt;

&lt;h2&gt;
  
  
  The pattern that made this worse than it needed to be
&lt;/h2&gt;

&lt;p&gt;I had an AI pair (Claude Code) writing most of the actual edits during this sprint. The AI is very good at producing plausible code fast. When I told it to add a test page with &lt;code&gt;useSearchParams()&lt;/code&gt; and a button, it wrote code that worked in dev mode — which is what AI training data is full of, because most demo apps run in dev.&lt;/p&gt;

&lt;p&gt;The Suspense boundary requirement is the kind of detail that lives in framework upgrade guides, not in tutorials. Training data doesn't catch it. I have to.&lt;/p&gt;

&lt;p&gt;The lesson isn't "AI bad." The lesson is that &lt;strong&gt;AI is great at execution and dangerous at diagnosis&lt;/strong&gt;. It can write the next line of code as fast as I can read it. But when something is wrong, it tends to confidently propose plausible explanations. If I act on the plausible ones without verifying, I waste an hour. If I reproduce first — actually click the button, actually read the build log — the wrong explanations get killed in three minutes.&lt;/p&gt;

&lt;p&gt;That's been the meta-pattern across every bug in this sprint. Plausible was wrong. Reproduction was right. Three minutes of curl/click/grep beat three hours of "let me try this fix."&lt;/p&gt;

&lt;h2&gt;
  
  
  Why I'm writing this
&lt;/h2&gt;

&lt;p&gt;I'm Aurin. I'm building &lt;a href="https://appstoreanalyzer.com" rel="noopener noreferrer"&gt;AppStoreAnalyzer&lt;/a&gt; — a tool that scores 50+ iOS app niches across 20 markets, so indie devs can see which niches have room before they spend three months coding. It's pre-launch. I'm writing a build-in-public log as I get to launch.&lt;/p&gt;

&lt;p&gt;This is post one. If you build iOS apps and want to look at niche data, the explorer is free and there's no signup wall. If you ever hit a Next.js 16 hydration bug, hopefully this post saved you an hour.&lt;/p&gt;

&lt;p&gt;More posts as the launch gets closer. If this bug made you wince in recognition, we'd get along.&lt;/p&gt;

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