<?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: Studio1</title>
    <description>The latest articles on DEV Community by Studio1 (studio1hq).</description>
    <link>https://dev.to/studio1hq</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%2Forganization%2Fprofile_image%2F9405%2Fdb6ebc30-ab35-43bc-a9cf-b27bcbb10046.png</url>
      <title>DEV Community: Studio1</title>
      <link>https://dev.to/studio1hq</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/studio1hq"/>
    <language>en</language>
    <item>
      <title>How to Add Crash Reporting and Session Replay to a React Native App</title>
      <dc:creator>Kathank Raithatha</dc:creator>
      <pubDate>Fri, 27 Nov 2026 18:32:48 +0000</pubDate>
      <link>https://dev.to/studio1hq/how-to-add-crash-reporting-and-session-replay-to-a-react-native-app-bgh</link>
      <guid>https://dev.to/studio1hq/how-to-add-crash-reporting-and-session-replay-to-a-react-native-app-bgh</guid>
      <description>&lt;p&gt;A user opens a note, starts typing, and the app closes. When they reopen it, the text they typed is gone.&lt;/p&gt;

&lt;p&gt;I reproduced exactly that in a React Native app, with a crash reporter installed and configured. Then I opened the dashboard and found nothing. No crash, and the last five seconds of the session were missing.&lt;/p&gt;

&lt;p&gt;This article covers how I set up crash reporting and session replay in that app. It also covers why the first crash never showed up, and the small component that fixed the gap. Everything below was run on a real release build on an Android emulator.&lt;/p&gt;

&lt;h2&gt;
  
  
  A stack trace tells you where. You also need why.
&lt;/h2&gt;

&lt;p&gt;Most production bugs in mobile apps don't fail on the line that's wrong. They fail because of state the app didn't expect: a slow network, a background sync, a record another device deleted a second ago.&lt;/p&gt;

&lt;p&gt;A crash report gives you the error, the stack trace, and device information. That's often enough to identify a missing null check, but it isn't enough when the real question is how the data ended up in that state. For that, you need to understand what happened leading up to the crash:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which screens the user went through.&lt;/li&gt;
&lt;li&gt;What they tapped.&lt;/li&gt;
&lt;li&gt;What network calls ran and what they returned.&lt;/li&gt;
&lt;li&gt;What your own code was doing, such as syncs, retries and cache updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's what session replay gives you. One thing to be clear about: in most of the observability tools, and in the one I used here, session replay is not a video. It's a timeline of events (screen views, taps, HTTP calls, logs, lifecycle changes and your own custom events), plus screenshots and layout snapshots. &lt;/p&gt;

&lt;p&gt;Basically you read it like a log that already knows which events belong to which user.&lt;/p&gt;

&lt;h2&gt;
  
  
  The app
&lt;/h2&gt;

&lt;p&gt;SyncNote is a small offline-first notes app built with Expo SDK 58 and React Native 0.88. Notes lives in a local database on the phone (Turso), and the app syncs with the server in the background. While the app is open, it pulls changes from other devices every 5 seconds.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwry2ghhh7l99r2m7oahq.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwry2ghhh7l99r2m7oahq.png" alt="The SyncNote notes list, online and synced" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That background pull is the interesting part. It means the data under the current screen can change while the user is looking at it, which is a common source of bugs that are hard to reproduce.&lt;/p&gt;

&lt;p&gt;The code is on &lt;a href="https://github.com/Studio1HQ/turso_measure_demo" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Install the SDK
&lt;/h2&gt;

&lt;p&gt;I used &lt;a href="https://measure.sh" rel="noopener noreferrer"&gt;Measure&lt;/a&gt;, an open-source tool for mobile crash reporting and session replay for production based applications. Measure's React Native SDK ships with an Expo config plugin, so you don't need to manually modify Android or iOS native files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx expo install @measuresh/react-native
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the plugin to &lt;code&gt;app.config.ts&lt;/code&gt; with the API key and URL from your Measure project:&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;// app.config.ts&lt;/span&gt;
&lt;span class="n"&gt;plugins&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="s1"&gt;'@measuresh/react-native'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;androidApiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;androidApiUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;iosApiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;iosApiUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_URL&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="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;The plugin writes the keys into the native project and starts the native SDKs when the app launches. On Android it also adds an OkHttp interceptor, which is what records HTTP calls. It edits native code, so you need a development build. Expo Go won't load it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx expo prebuild --platform android --clean
npx expo run:android
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then initialize the JavaScript side as early as possible, before your first screen renders:&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;// src/telemetry.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MeasureConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@measuresh/react-native'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MeasureConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;enableLogging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;__DEV__&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Open the app and interact with a few screens. A session should appear in the dashboard within a minute. Since events are sent in batches, moving the app to the background can help trigger an earlier upload.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Make release stack traces readable
&lt;/h2&gt;

&lt;p&gt;Your release bundle is minified. Without a sourcemap, every frame in a JavaScript stack trace points to &lt;code&gt;index.android.bundle&lt;/code&gt; at some column, which tells you nothing.&lt;/p&gt;

&lt;p&gt;On Android, the Measure Gradle plugin handles this. It uploads the sourcemap whenever you build a release. You can see it in the build output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; Task :app:rewriteReactNativeSourceMapRelease
&amp;gt; Task :app:packageReactNativeSourceMapRelease
&amp;gt; Task :app:uploadReleaseBuildToMeasure
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result is a stack trace that points to the file and line you wrote, like &lt;code&gt;src/screens/NoteEditor.tsx:126:33&lt;/code&gt;. On iOS, you can upload script as a build phase instead. The &lt;a href="https://measure.sh/docs/error-monitoring/upload-symbols" rel="noopener noreferrer"&gt;symbol upload docs&lt;/a&gt; covers both.&lt;/p&gt;

&lt;p&gt;Always test crashes in a release build. Debug builds handle errors differently, often displaying a red error screen instead of closing the app, while stack traces reference the development bundle rather than the production bundle.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Record the events that explain your bugs
&lt;/h2&gt;

&lt;p&gt;Automatic event covers screens, taps and network calls. They don't know what your app means by "sync" or "conflict". For that, track your own events, and keep them small: ids, counts and timings, never user content.&lt;/p&gt;

&lt;p&gt;I wrapped every call in one file, so the event names stay consistent:&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;// src/telemetry.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;EventName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attrs&lt;/span&gt;&lt;span class="o"&gt;?:&lt;/span&gt; &lt;span class="nc"&gt;Attrs&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trackEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;attrs&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="p"&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="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;The event that ended up mattering most was the one I almost didn't add. It records what each background pull brought in:&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;// src/store.tsx, after a pull that changed something&lt;/span&gt;
&lt;span class="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'remote_changes_received'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;notes_changed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;changedNotes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;notes_removed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;removed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;pull_ms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;pullMs&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;If your app modifies data without direct user interaction, whether through background sync, push notifications, WebSockets, or a cache refresh, log those changes. They often go unnoticed in crash reports but can be the underlying cause of a crash.&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug
&lt;/h2&gt;

&lt;p&gt;Here's the line that caused the crash. The note editor shows when the note was last edited:&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;// src/screens/NoteEditor.tsx (the buggy version)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;noteId&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="n"&gt;noteId&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt; &lt;span class="n"&gt;style&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;styles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nc"&gt;Edited&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;timeAgo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; · &lt;span class="n"&gt;rev&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Text&lt;/span&gt;&lt;span class="o"&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;It checks that a note id exists, then assumes the note does too. Usually that's true. It isn't when another device deletes the note while it's open here.&lt;/p&gt;

&lt;p&gt;To reproduce it, I opened a note on the phone and started typing:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe0frqk6swlcoudbgfik5.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fe0frqk6swlcoudbgfik5.png" alt="The note editor with a half-typed sentence" width="800" height="770"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then I deleted the same note from a second device, a script that writes straight to the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run remote:delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;About four seconds later, the next background pull removed the note from the list. The editor re-rendered with &lt;code&gt;note&lt;/code&gt; set to &lt;code&gt;undefined&lt;/code&gt;, and the app closed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FATAL EXCEPTION: mqt_v_native
com.facebook.react.common.JavascriptException:
  TypeError: Cannot read property 'updated_at' of undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The user's text was lost. It was never saved, because they hadn't tapped Save yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the crash never showed up
&lt;/h2&gt;

&lt;p&gt;I gave it time, reopened the app so pending data could upload, and checked again. The session was there, but it stopped five seconds before the crash. The crash itself never arrived.&lt;/p&gt;

&lt;p&gt;To understand why this happens, I went through the SDK's source code, followed by React Native's. The SDK captures JavaScript crashes by hooking into React Native's global error handler, &lt;code&gt;ErrorUtils.setGlobalHandler&lt;/code&gt;, which is a common approach. Uncaught errors in timers, event handlers, and listeners pass through this handler. However, errors thrown during React's rendering process took a different path. React Native passes them directly to its exceptions manager:&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;// node_modules/react-native/Libraries/Core/ReactFiberErrorDialog.js&lt;/span&gt;
&lt;span class="nc"&gt;ExceptionsManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;handleException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&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;So the global handler is never called, and the crash reporter listening on it never sees the error. In a release build, the app then closes from the native side.&lt;/p&gt;

&lt;p&gt;I checked the other path to confirm, in a debug build. I threw an error inside a &lt;code&gt;setTimeout&lt;/code&gt; callback, and it arrived in the dashboard as a fatal crash, as expected. Errors from callbacks reach the handler. Errors from render don't.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F75xu6f0ilvn453ctrxen.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F75xu6f0ilvn453ctrxen.png" alt="Where a React Native JS error goes: callbacks reach the global handler, render errors skip it, and an error boundary reports them" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Tested on React Native 0.88 with &lt;code&gt;@measuresh/react-native&lt;/code&gt; 0.5.1. Run this check on your own stack: throw during render in a release build and see whether it reaches your dashboard.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Handle React Rendering Errors Using an Error Boundary
&lt;/h2&gt;

&lt;p&gt;React already has a tool for errors during render: an error boundary. It's a class component that catches errors in the components below it. Most guides use it to show a fallback screen. It's also the right place to report the error, because in this setup it's the one place your code gets to see it.&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;// src/components/ErrorBoundary.tsx (simplified)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ErrorBoundary&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Component&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Props&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;State&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;getDerivedStateFromError&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="nc"&gt;State&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="n"&gt;failed&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="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;componentDidCatch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ErrorInfo&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trackError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'error_boundary'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;component_stack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;componentStack&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s1"&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;trim&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="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="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;render&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;state&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;failed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;props&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;children&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Fallback&lt;/span&gt; &lt;span class="n"&gt;onReset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reset&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="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;I wrapped each screen in its own boundary, with a &lt;code&gt;key&lt;/code&gt;, so a failure on one screen doesn't take down the rest of the app, and navigating away resets it:&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;// src/App.tsx (simplified)&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ErrorBoundary&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sb"&gt;`editor-${noteId}`&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"NoteEditor"&lt;/span&gt; &lt;span class="n"&gt;onReset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;toList&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;NoteEditor&lt;/span&gt; &lt;span class="n"&gt;noteId&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;noteId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;onClose&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;toList&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;ErrorBoundary&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I rebuilt the release with the boundary and the same bug, and ran the same steps. This time the app stayed opened and showed the fallback:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd99f1gkaelaknvlpvxx1.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fd99f1gkaelaknvlpvxx1.png" alt="The fallback screen: &amp;quot;Something went wrong on this screen&amp;quot; with a Back to notes button" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The error arrived in the dashboard with a readable stack trace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TypeError: Cannot read property 'updated_at' of undefined
    at NoteEditor (src/screens/NoteEditor.tsx:126:33)
    at renderWithHooks (node_modules/react-native/.../ReactFabric-prod.js:3871:30)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two things I didn't expect:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;It's reported as a handled error, not a crash&lt;/strong&gt;. The &lt;code&gt;trackError&lt;/code&gt; method reports handled errors, which Measure doesn't actively sample by default. Session replay is also disabled for these errors. Head to the Adaptive Capture settings in the dashboard, increase the handled error sampling rate, and enable session replay. Otherwise, you might ship the error boundary without seeing the errors it catches.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;The component stack may remain minified in release builds&lt;/strong&gt;. While the main JavaScript stack trace is symbolicated using source maps, the componentStack string provided by React may still contain minified references and bundle offsets. It's worth capturing because it can provide additional context about the component hierarchy where the error occurred.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Reading the session
&lt;/h2&gt;

&lt;p&gt;Here's the session around that error, straight from the timeline:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time (UTC)&lt;/th&gt;
&lt;th&gt;Event&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;13:09:54.794&lt;/td&gt;
&lt;td&gt;Tap on "Product Launch Plan"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:09:54.832&lt;/td&gt;
&lt;td&gt;Screen view: &lt;code&gt;NoteEditor&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:09:58.200&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;note_edited&lt;/code&gt;: the user starts typing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:10:06.695&lt;/td&gt;
&lt;td&gt;Background pull, HTTP 200&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:10:06.733&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;remote_changes_received&lt;/code&gt; with &lt;code&gt;notes_removed: 1&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:10:06.743&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;TypeError&lt;/code&gt; in &lt;code&gt;NoteEditor&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:10:20.620&lt;/td&gt;
&lt;td&gt;Tap on "Back to notes"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsuk4s6rmqmnptnffhvip.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsuk4s6rmqmnptnffhvip.png" alt="Where it broke vs. why it broke: the error report next to the session timeline" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The stack trace says &lt;code&gt;note&lt;/code&gt; was undefined in the editor. The session explains why. The user was editing a note, a background pull removed exactly one note, and 10 milliseconds later the editor failed. The note under the open editor was deleted somewhere else.&lt;/p&gt;

&lt;p&gt;None of that was in the error report. And without the &lt;code&gt;remote_changes_received&lt;/code&gt; event, the timeline would have shown an HTTP 200 followed by an error, which tells you a lot less.&lt;/p&gt;

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

&lt;p&gt;The one-line fix is to check &lt;code&gt;note&lt;/code&gt; instead of &lt;code&gt;noteId&lt;/code&gt;. But the session showed what the user was in the middle of, typing, so the real fix should also protect their text:&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;// src/screens/NoteEditor.tsx&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;noteId&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;notes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;find&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;noteId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;deletedElsewhere&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;!!&lt;/span&gt;&lt;span class="n"&gt;noteId&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;note&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;useEffect&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="o"&gt;=&amp;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="n"&gt;deletedElsewhere&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'note_deleted_remotely'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;note_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;noteId&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;had_unsaved_edit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;editTracked&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;deletedElsewhere&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="c1"&gt;// Save as a new note if the original is gone&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;saveNote&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deletedElsewhere&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;noteId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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="n"&gt;content&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;Now the editor tells the user what happened and keeps what they typed:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frjbk76wfk0hf04ew9son.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frjbk76wfk0hf04ew9son.png" alt="The editor showing &amp;quot;This note was deleted on another device. Your text is still here.&amp;quot;" width="800" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tapping "Save as new note" keeps the text, and it syncs like any other note:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxhdx8madsqaw44qawmnb.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxhdx8madsqaw44qawmnb.png" alt="The notes list with the saved note at the top" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The new &lt;code&gt;note_deleted_remotely&lt;/code&gt; event means that the next time this happens in production, it shows up in the data as a normal event rather than an error. &lt;code&gt;had_unsaved_edit: true&lt;/code&gt; tells you how often users would have lost work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd tell anyone setting this up
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test crash reporting in a release build.&lt;/strong&gt; Debug builds handle errors differently and use a separate JavaScript bundle. An error that triggers a red screen during development may not be captured the same way in production. That's why it's important to test crash reporting in a release build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Throw an error during render on purpose and check that it arrives.&lt;/strong&gt; Then throw one in a timer. If only one of them shows up, you've found the same gap I did.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put an error boundary around each screen, and report from &lt;code&gt;componentDidCatch&lt;/code&gt;.&lt;/strong&gt; You get the error, a fallback instead of a closed app, and the rest of the session keeps recording.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Upload sourcemaps as part of the release build,&lt;/strong&gt; not as a manual step you'll forget.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Log the state changes your users didn't make.&lt;/strong&gt; Sync results, pushes and cache refreshes are what turn a session timeline from "something happened" into the cause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check your sampling settings.&lt;/strong&gt; Default settings for handled errors and replays are usually conservative to keep costs down, which is also how your most useful errors go missing.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it yourself
&lt;/h2&gt;

&lt;p&gt;The app and every snippet above are in the &lt;a href="https://github.com/Studio1HQ/turso_measure_demo" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;. The repo has the fix. To bring the bug back, change &lt;code&gt;{note &amp;amp;&amp;amp; (&lt;/code&gt; to &lt;code&gt;{noteId &amp;amp;&amp;amp; (&lt;/code&gt; above the "Edited …" line in &lt;code&gt;src/screens/NoteEditor.tsx&lt;/code&gt;. Then build a release, open a note, and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run remote:delete
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then compare what reaches your dashboard with and without the error boundary.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;If you love my content ❤️ Follow me on &lt;a href="https://www.linkedin.com/in/kathank/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
~ Kathank Raithatha&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>mobile</category>
      <category>observability</category>
    </item>
    <item>
      <title>Inference Economics: Clearly Explained</title>
      <dc:creator>Shivam Katare</dc:creator>
      <pubDate>Thu, 26 Nov 2026 13:27:08 +0000</pubDate>
      <link>https://dev.to/studio1hq/why-every-second-matters-in-a-multi-step-ai-agent-fp8-nvfp4-and-inference-economics-80d</link>
      <guid>https://dev.to/studio1hq/why-every-second-matters-in-a-multi-step-ai-agent-fp8-nvfp4-and-inference-economics-80d</guid>
      <description>&lt;p&gt;When you chat with a model, you ask once and wait once.&lt;/p&gt;

&lt;p&gt;Agents don't work like that.&lt;/p&gt;

&lt;p&gt;An agent fixing a bug reads a file, thinks, runs the tests, thinks again, edits the code, and runs the tests once more. Each of those steps is a new call to the model, and each call makes you wait.&lt;/p&gt;

&lt;p&gt;So a model that takes one extra second per reply doesn't cost you one second. In a 17-turn task, it costs you seventeen.&lt;/p&gt;

&lt;p&gt;That's why model speed matters far more in agents than in chat. It's also why formats like FP8(8-bit Floating Point) and NVFP4(NVIDIA 4-Bit Floating Point) are worth understanding. They make models smaller so they can reply faster.&lt;/p&gt;

&lt;p&gt;Most writing about these formats stays at the chip level: bits, blocks, and &lt;a href="https://www.ionos.com/digitalguide/server/know-how/pflops/#:~:text=One%20petaFLOPS%20(PFLOPS)%20is%20equal%20to%201015%20FLOPS%20or%20one%20quadrillion%20floating%20point%20op%C2%ADer%C2%ADa%C2%ADtions%20per%20second.%20The%20unit%20is%20used%20to%20measure%20the%20power%20of%20high-per%C2%ADfor%C2%ADmance%20computers" rel="noopener noreferrer"&gt;petaFLOPS&lt;/a&gt;. Very little of it shows what happens inside a real agent loop.&lt;/p&gt;

&lt;p&gt;So today we'll do both.&lt;/p&gt;

&lt;p&gt;First, we'll learn what FP8 and NVFP4 actually are. Then we'll build a small coding agent on DeepSeek-V4.1-Flash-1017-fast from &lt;a href="https://nebius.com/services/token-factory" rel="noopener noreferrer"&gt;Nebius Token Factory&lt;/a&gt;, give it a real bug hunt across several files, and time every turn.&lt;/p&gt;

&lt;p&gt;I picked this model because &lt;a href="https://tokenfactory.nebius.com/models/catalog/image2text/deepseek-ai/DeepSeek-V4.1-Flash-1017-fast" rel="noopener noreferrer"&gt;Nebius lists it&lt;/a&gt; as served in FP8, one of the two formats this article is about. So the numbers come from a real FP8 endpoint, not a lab setup.&lt;/p&gt;

&lt;p&gt;We won't race FP8 against NVFP4 here. Instead, we'll measure where a real agent's time and money go, because that tells you how much a faster format can actually matter.&lt;/p&gt;

&lt;p&gt;Finally, we'll connect the two and see which part of the loop a smaller format would speed up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TL;DR&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The agent fixed 3 bugs spread across a billing service in 17 turns. The test suite went from 7 failing tests to all 16 passing.&lt;/li&gt;
&lt;li&gt;Writing was fast: about 900 tokens per second. Even the biggest reasoning turn, 2,286 tokens, took only 2.5 seconds to write.&lt;/li&gt;
&lt;li&gt;The wait before each reply stayed flat at about one second while the prompt grew 14x, because most of it was cached. But paid on all 17 turns, that one second added up to 17 seconds, almost twice the time spent writing.&lt;/li&gt;
&lt;li&gt;The model spent 27 seconds on the whole task, and 17 of them were that one-second wait before each reply. On a fast endpoint, the number of turns matters more than how fast tokens come out.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: See why an agent pays for latency again and again
&lt;/h2&gt;

&lt;p&gt;A chat request is a straight line. You send a prompt, the model replies, and you're done.&lt;/p&gt;

&lt;p&gt;An agent is a loop:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The model decides what to do next.&lt;/li&gt;
&lt;li&gt;It calls a tool, like reading a file or running tests.&lt;/li&gt;
&lt;li&gt;The tool's output is added to the conversation.&lt;/li&gt;
&lt;li&gt;The whole conversation goes back to the model, and the loop starts again.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That last step is the one people miss.&lt;/p&gt;

&lt;p&gt;The model doesn't remember the previous turn. Every turn, the agent sends the full history again: the system prompt, the task, every file it has read, and every test result so far.&lt;/p&gt;

&lt;p&gt;So the prompt keeps growing. In the run we'll look at later, it started at 737 tokens on turn 1 and reached 10,938 tokens by turn 18.&lt;/p&gt;

&lt;p&gt;Researchers at UC San Diego saw the same pattern when they timed computer-use agents in &lt;a href="https://arxiv.org/abs/2506.16042" rel="noopener noreferrer"&gt;OSWorld-Human&lt;/a&gt;. They found that "the prompt sent to the LLM includes the history of all previous steps", and that "each successive step can take 3x longer than steps at the beginning of a task."&lt;/p&gt;

&lt;p&gt;They also found where the time goes: model calls for planning, reflection, and judging "account for most of the overall latency." The tools weren't the bottleneck. The model was.&lt;/p&gt;

&lt;p&gt;In an agent, latency isn't paid once. It's paid on every turn.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffeb7y0cn0w2iekxdum2x.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ffeb7y0cn0w2iekxdum2x.png" alt="Single-turn chat call vs. a 17-turn agent loop with growing prompt history." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's the frame for the rest of this article. Any second we save on a single model call gets saved again on every turn of the loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Understand what the model is doing while you wait
&lt;/h2&gt;

&lt;p&gt;Every model reply happens in two phases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prefill&lt;/strong&gt; is the model reading your prompt. It processes all the input tokens together, in parallel, so it's mostly a lot of math. The time you spend waiting for this is roughly the time to first token (TTFT).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decode&lt;/strong&gt; is the model writing its reply. It produces one token, then the next, then the next. It can't skip ahead because each token depends on the one before it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The two phases hit different limits.&lt;/p&gt;

&lt;p&gt;Prefill is limited by how fast the GPU can do math. Decode is limited by how fast the GPU can read from its own memory. To write each new token, the GPU has to pull the model's weights out of memory again, and there's very little math to do per token. So most of the time goes to moving bytes, not computing.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://arxiv.org/abs/2410.13461" rel="noopener noreferrer"&gt;authors of the PMPD paper&lt;/a&gt; put it in one line: "&lt;em&gt;the prefill phase is known to be compute-bound, while the decoding stage is memory-bound.&lt;/em&gt;" They also note that inference latency "&lt;em&gt;is typically dominated by the decoding phase.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Here's a preview from our run. On the agent's heaviest turn, the model started replying after 1.05 seconds, then spent 2.50 seconds writing 2,286 tokens.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6gxnwtphlot7wjojqikj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F6gxnwtphlot7wjojqikj.png" alt="Prefill vs. decode breakdown of a single agent turn." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That leads to the key idea behind this whole article:&lt;/p&gt;

&lt;p&gt;Smaller weights mean fewer bytes to read per token, and fewer bytes mean faster tokens.&lt;/p&gt;

&lt;p&gt;That's exactly what FP8 and NVFP4 do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Learn what FP8 and NVFP4 actually change
&lt;/h2&gt;

&lt;p&gt;A model is billions of numbers called weights. The question is how many bits each one gets.&lt;/p&gt;

&lt;p&gt;Models are usually trained in 16-bit formats, which means 2 bytes per weight. A model with 100 billion weights needs about 200 GB just to hold them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FP8&lt;/strong&gt; cuts that in half. Each weight gets 8 bits, so 1 byte.&lt;/p&gt;

&lt;p&gt;But what do those 8 bits actually hold?&lt;/p&gt;

&lt;p&gt;A floating-point number works like scientific notation. Take 6.02 × 10²³. The 6.02 carries the precision, and the 23 carries the size. Computers store numbers the same way, in binary:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1 sign bit: plus or minus.&lt;/li&gt;
&lt;li&gt;Exponent bits: how big or small the number is. This is the&amp;nbsp;23.&lt;/li&gt;
&lt;li&gt;Mantissa bits: how precise it is. This is the 6.02.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With only 8 bits, you have to choose how to split them between size and precision.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://arxiv.org/abs/2209.05433" rel="noopener noreferrer"&gt;joint paper&lt;/a&gt; from NVIDIA, Arm, and Intel defined the two splits that became the FP8 standard:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;E4M3: 4 exponent bits and 3 mantissa bits. More precision, smaller range.&lt;/li&gt;
&lt;li&gt;E5M2: 5 exponent bits and 2 mantissa bits. More range, less precision.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For running models, the paper recommends "E4M3 for weight and activation tensors". E5M2 is mainly for training.&lt;/p&gt;

&lt;p&gt;Keep E4M3 in mind, because it shows up again in a moment.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn405p9s67im6nlq3uw2x.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn405p9s67im6nlq3uw2x.png" alt="Bit-level layout of FP8 (E4M3, E5M2) and FP4 (E2M1) formats. Each box is the same width, so the FP4 row is visibly half as long as the FP8 rows." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;FP4 halves it again. The &lt;a href="https://arxiv.org/abs/2310.10537" rel="noopener noreferrer"&gt;Microscaling (MX)&lt;/a&gt; standard's 4-bit format is E2M1: 1 sign bit, 2 exponent bits and 1 mantissa bit.&lt;/p&gt;

&lt;p&gt;That gives only 16 possible bit patterns, which is far too few to represent real weights directly.&lt;/p&gt;

&lt;p&gt;The fix is called block scaling.&lt;/p&gt;

&lt;p&gt;You split the weights into small blocks and give each block its own scale factor. The 4-bit values store the shape of the numbers inside the block, and the scale stretches them back to their real size.&lt;/p&gt;

&lt;p&gt;Think of it as giving every small group of numbers its own zoom level.&lt;/p&gt;

&lt;p&gt;The open MX standard does this with blocks of 32 values. Each block shares one scale, and that scale can only be a power of two.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.nvidia.com/blog/introducing-nvfp4-for-efficient-and-accurate-low-precision-inference/" rel="noopener noreferrer"&gt;&lt;strong&gt;NVFP4&lt;/strong&gt;&lt;/a&gt; is NVIDIA's version, and it changes two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Smaller blocks. Each block has 16 values instead of&amp;nbsp;32. If one weight in a block is unusually large, it distorts 15 neighbors instead of&amp;nbsp;31.&lt;/li&gt;
&lt;li&gt;Finer scales. Each block's scale is stored in FP8 (E4M3), so it isn't limited to powers of two and can match the block more closely. On top of that, one FP32 scale covers the whole tensor.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The cost of all those scales is small. NVIDIA describes it as "one 4-bit value plus minor overhead of one FP8 scale per 16 values (4.5 bits per value)."&lt;/p&gt;

&lt;p&gt;That's 4 bits for the value plus 8 ÷ 16 = 0.5 bits for its share of the scale.&lt;/p&gt;

&lt;p&gt;The result, according to NVIDIA: memory drops "approximately 3.5x relative to FP16, and approximately 1.8x compared to FP8."&lt;/p&gt;

&lt;p&gt;That's the format-level number. On a real model, some layers stay in higher precision. NVIDIA's NVFP4 release of DeepSeek-R1-0528 reports about 1.6x less disk and GPU memory than FP8.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F73xmao1wvqd864xm561a.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F73xmao1wvqd864xm561a.png" alt="Memory footprint comparison between FP8 and NVFP4 block scaling." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember Step 2: decode is limited by how many bytes the GPU reads per token. Fewer bytes per weight attacks that limit directly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Check whether a 4-bit model still gets the answer right
&lt;/h2&gt;

&lt;p&gt;Smaller weights are only useful if the model stays smart.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://huggingface.co/nvidia/DeepSeek-R1-0528-NVFP4" rel="noopener noreferrer"&gt;NVIDIA published&lt;/a&gt; an NVFP4 version of DeepSeek-R1-0528 with scores next to the FP8 reference. Here are three from the model card:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Benchmark&lt;/th&gt;
&lt;th&gt;FP8&lt;/th&gt;
&lt;th&gt;NVFP4&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;LiveCodeBench (coding)&lt;/td&gt;
&lt;td&gt;77&lt;/td&gt;
&lt;td&gt;76.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MMLU Pro (knowledge)&lt;/td&gt;
&lt;td&gt;85&lt;/td&gt;
&lt;td&gt;84.2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AIME 2024 (competition math)&lt;/td&gt;
&lt;td&gt;89&lt;/td&gt;
&lt;td&gt;91.3&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The coding score dropped by less than one point. On AIME it even went up a little.&lt;/p&gt;

&lt;p&gt;NVIDIA's own summary is "1% or less accuracy degradation on key language modeling tasks."&lt;/p&gt;

&lt;p&gt;Now for speed, memory is one half of the story, and the other half is the hardware that does the math.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.nvidia.com/blog/inside-nvidia-blackwell-ultra-the-chip-powering-the-ai-factory-era/" rel="noopener noreferrer"&gt;NVIDIA's Blackwell Ultra&lt;/a&gt; spec table lists 15 petaFLOPS of dense NVFP4 compute against 5 petaFLOPS for FP8. That's 3x on paper.&lt;/p&gt;

&lt;p&gt;These are peak numbers, and peak numbers only show up when the serving stack actually runs 4-bit kernels.&lt;/p&gt;

&lt;p&gt;The format alone does nothing. Two things decide whether you ever see the speedup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the GPU the model runs on&lt;/li&gt;
&lt;li&gt;the inference engine serving it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The model in our benchmark is a real case of this. We know its format is FP8, so our numbers come from an FP8 model in production, not from a spec sheet. What we can't see from outside is which GPU and engine sit behind it.&lt;/p&gt;

&lt;p&gt;So the question for an agent builder isn't "is NVFP4 faster?" It's "where does my agent actually spend its time?"&lt;/p&gt;

&lt;p&gt;That's what we'll measure next.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Build a real multi-step task for the agent
&lt;/h2&gt;

&lt;p&gt;To see where an agent's time goes, it needs a task that actually takes many steps.&lt;/p&gt;

&lt;p&gt;So I built a small async billing service: 6 Python modules, a log file, a changelog, and 16 tests. Then I planted 3 bugs that cross file boundaries:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A race condition in the rate limiter. Two requests read the counter at the same time, so a client allowed 10 requests got 25 through.&lt;/li&gt;
&lt;li&gt;Rounding in the wrong place. Each event was rounded to the cent instead of only the invoice total, so tiny events were billed as $0.00.&lt;/li&gt;
&lt;li&gt;A schema change that broke old clients. A field that should be optional became required, so events from the older SDK were rejected.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The suite starts at 7 failing and 9 passing. The agent gets a short incident report, like the one a teammate would file, and doesn't know where the bugs are. It also can't edit the tests.&lt;/p&gt;

&lt;p&gt;It gets five tools: &lt;code&gt;list_files&lt;/code&gt;, &lt;code&gt;read_file&lt;/code&gt;, &lt;code&gt;search_code&lt;/code&gt;, &lt;code&gt;run_pytest&lt;/code&gt; and &lt;code&gt;apply_patch&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The agent itself is a short loop. Call the model, run the tools it asks for, add the results to the history, and go again:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;messages&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="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"system"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;SYSTEM_PROMPT&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="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;TASK&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;turn&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nb"&gt;range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="no"&gt;MAX_TURNS&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tool_calls&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;timing&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;stream_turn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;tool_calls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;          &lt;span class="c1"&gt;# no more tools needed: final answer&lt;/span&gt;
    &lt;span class="k"&gt;break&lt;/span&gt;

&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;tool_calls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;output&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;workspace&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loads&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"arguments"&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="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"tool"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"tool_call_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="c1"&gt;#&amp;lt;------ messages&lt;/span&gt;
                     &lt;span class="s2"&gt;"content"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;output&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;Notice that messages only ever grows. That's the history from Step 1, sent again on every turn.&lt;/p&gt;

&lt;p&gt;The agent talks to the model through an OpenAI-compatible API, so the standard OpenAI Python client works as is.&lt;/p&gt;

&lt;p&gt;Every call is streamed, so each turn can be split into the two phases from Step 2. Here is the timing core:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;t_start&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;t_first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt;

&lt;span class="n"&gt;stream&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;chat&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;completions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="n"&gt;model&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;MODEL_ID&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;tools&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="no"&gt;TOOLS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;True&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;stream_options&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"include_usage"&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="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;stream&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="n"&gt;usage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;usage&lt;/span&gt;          &lt;span class="c1"&gt;# arrives in the last chunk&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;span class="k"&gt;continue&lt;/span&gt;
&lt;span class="n"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;chunk&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;choices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;
&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;t_first&lt;/span&gt; &lt;span class="k"&gt;is&lt;/span&gt; &lt;span class="kc"&gt;None&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="n"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;tool_calls&lt;/span&gt; &lt;span class="ow"&gt;or&lt;/span&gt; &lt;span class="nf"&gt;reasoning_in&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;delta&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="n"&gt;t_first&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# first real token&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="n"&gt;t_end&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;perf_counter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;ttft&lt;/span&gt;   &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t_first&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t_start&lt;/span&gt;   &lt;span class="c1"&gt;# queue + prefill&lt;/span&gt;
&lt;span class="n"&gt;decode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;t_end&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;t_first&lt;/span&gt;     &lt;span class="c1"&gt;# writing tokens&lt;/span&gt;
&lt;span class="n"&gt;cached&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;usage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;prompt_tokens_details&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cached_tokens&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two details matter here.&lt;/p&gt;

&lt;p&gt;First, the TTFT clock stops on the first real token, which includes reasoning tokens. Otherwise, a model that thinks quietly before answering would look slow to start.&lt;/p&gt;

&lt;p&gt;Second, &lt;code&gt;include_usage&lt;/code&gt; gives exact token counts per turn, including how many input tokens were served from cache.&lt;/p&gt;

&lt;p&gt;The model and prices are environment variables, so anyone can rerun the same task on another endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;MODEL_ID&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;deepseek-ai/DeepSeek-V4.1-Flash-1017-fast &lt;span class="nv"&gt;PRICE_INPUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.60 &lt;span class="nv"&gt;PRICE_CACHE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0.012 &lt;span class="nv"&gt;PRICE_OUTPUT&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;2.40 \
python run_benchmark.py

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every turn is saved to &lt;code&gt;benchmark_results.json&lt;/code&gt;: tools called, TTFT, decode time, tokens, cache hits, and cost.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: Run it and time every turn
&lt;/h2&gt;

&lt;p&gt;The agent solved it.&lt;/p&gt;

&lt;p&gt;It took 17 turns to go from 7 failing tests to all 16 passing. It found all three bugs, fixed each one in the right file, and reran the tests to confirm.&lt;/p&gt;

&lt;p&gt;Here are six of the 17 turns:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Turn&lt;/th&gt;
&lt;th&gt;What it did&lt;/th&gt;
&lt;th&gt;TTFT&lt;/th&gt;
&lt;th&gt;Decode&lt;/th&gt;
&lt;th&gt;Model total&lt;/th&gt;
&lt;th&gt;Prompt tokens&lt;/th&gt;
&lt;th&gt;Output tokens&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;list files&lt;/td&gt;
&lt;td&gt;1.15s&lt;/td&gt;
&lt;td&gt;0.01s&lt;/td&gt;
&lt;td&gt;1.16s&lt;/td&gt;
&lt;td&gt;737&lt;/td&gt;
&lt;td&gt;31&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;run tests&lt;/td&gt;
&lt;td&gt;0.94s&lt;/td&gt;
&lt;td&gt;0.70s&lt;/td&gt;
&lt;td&gt;1.64s&lt;/td&gt;
&lt;td&gt;5,518&lt;/td&gt;
&lt;td&gt;637&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;plan + first fix&lt;/td&gt;
&lt;td&gt;1.05s&lt;/td&gt;
&lt;td&gt;2.50s&lt;/td&gt;
&lt;td&gt;3.56s&lt;/td&gt;
&lt;td&gt;6,903&lt;/td&gt;
&lt;td&gt;2,286&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;patch&lt;/td&gt;
&lt;td&gt;0.98s&lt;/td&gt;
&lt;td&gt;1.84s&lt;/td&gt;
&lt;td&gt;2.81s&lt;/td&gt;
&lt;td&gt;8,479&lt;/td&gt;
&lt;td&gt;1,486&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;td&gt;run tests x2&lt;/td&gt;
&lt;td&gt;1.19s&lt;/td&gt;
&lt;td&gt;0.85s&lt;/td&gt;
&lt;td&gt;2.04s&lt;/td&gt;
&lt;td&gt;10,136&lt;/td&gt;
&lt;td&gt;745&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;17&lt;/td&gt;
&lt;td&gt;final answer&lt;/td&gt;
&lt;td&gt;1.06s&lt;/td&gt;
&lt;td&gt;0.95s&lt;/td&gt;
&lt;td&gt;2.00s&lt;/td&gt;
&lt;td&gt;10,259&lt;/td&gt;
&lt;td&gt;863&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;All 17&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;17.41s&lt;/td&gt;
&lt;td&gt;9.59s&lt;/td&gt;
&lt;td&gt;27.00s&lt;/td&gt;
&lt;td&gt;110,412&lt;/td&gt;
&lt;td&gt;8,685&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The data shows three things.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Writing was fast.&lt;/strong&gt; The model wrote at about 900 tokens per second. On turn 7, it reasoned through all three bugs at once and wrote 2,286 tokens, and that took 2.5 seconds. Across the whole run, all the writing added up to under 10 seconds.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The wait before each reply was the bigger cost.&lt;/strong&gt; The prompt grew 14x, from 737 to 10,259 tokens, but time to first token stayed at about one second per turn, because 90.7% of the input was served from cache. That one second never went away, though. Paid on 17 turns, it came to 17.4 seconds, which is 64% of the model's time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The tools were quick.&lt;/strong&gt; The test runs took 24.8 seconds on my laptop, but most of that was Windows starting Python. The tests themselves ran in about 2.5 seconds in total. On a normal machine, the model is most of the wait.&lt;/li&gt;
&lt;/ol&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fszliiv80xvx4cy25sk9k.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fszliiv80xvx4cy25sk9k.png" alt="Turn-by-turn breakdown of TTFT, decode, and tool execution across all 18 agent turns." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Remember PMPD's claim from Step 2, that latency is usually dominated by decode? On this endpoint, it wasn't. Decode is still the memory-bound phase. It's just fast enough here that the fixed cost of each turn now outweighs it.&lt;/p&gt;

&lt;p&gt;The slow part of this agent wasn't writing. It was how many times it had to ask.&lt;/p&gt;

&lt;p&gt;I ran the same task again, and the agent finished in 14 turns and 45.5 seconds. Same bugs, same model, three fewer turns. In an agent, the number of turns is part of the latency.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Connect the numbers back to FP8 and NVFP4
&lt;/h2&gt;

&lt;p&gt;Put the run next to Step 2, and the pattern is clear.&lt;/p&gt;

&lt;p&gt;This endpoint is already FP8, and its decode is fast. Writing took 9.59 of the 27 seconds spent on the model, which is 36%. The other 64% was the one-second wait before each reply, and caching had already kept the prefill part of that small.&lt;/p&gt;

&lt;p&gt;Money is a different story. Output tokens cost $0.0208 of the run's $0.0282 total, which is 74%. So even when writing is fast, it's still where most of the money goes.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsj90kvzxgx9yqh83042c.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsj90kvzxgx9yqh83042c.png" alt="Time and cost breakdown across prefill, decode, and tool execution." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now put the two ideas from earlier together:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;From Step 2: smaller weights mean fewer bytes per token, and fewer bytes mean faster tokens.&lt;/li&gt;
&lt;li&gt;From Step 1: any second saved on one model call is saved again on every turn of the loop.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A smaller format like NVFP4 works on the writing part. On this run, that's 36% of the model's time and 74% of the cost, paid on every turn.&lt;/p&gt;

&lt;p&gt;But it can't help with the one-second wait before each reply. Most of that second is the request traveling to the server and waiting its turn, and a smaller format doesn't change either. The only way to cut that wait is to make fewer calls.&lt;/p&gt;

&lt;p&gt;So a smaller format saves time on the writing, 17 times over. Once writing is this fast, though, the biggest second left is the one you wait before every reply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrap-up
&lt;/h2&gt;

&lt;p&gt;A single request hides all of this. You only see it when you time the loop.&lt;/p&gt;

&lt;p&gt;If you're picking a model or an endpoint for an agent, measure four things in your own task:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how many turns it takes&lt;/li&gt;
&lt;li&gt;how long you wait for the first token on each turn, compared with how long the writing takes&lt;/li&gt;
&lt;li&gt;your cache hit rate&lt;/li&gt;
&lt;li&gt;the one big reasoning turn&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then rerun the same task when you change something, whether that's the model, the precision or the provider.&lt;/p&gt;

&lt;p&gt;I ran everything here on &lt;a href="https://nebius.com/services/token-factory" rel="noopener noreferrer"&gt;Nebius Token Factory&lt;/a&gt;, so that's an easy place to start if you want to reproduce these numbers. The benchmark works with any OpenAI-compatible endpoint, though, so point &lt;code&gt;MODEL_ID&lt;/code&gt; at whichever model you're curious about and compare.&lt;/p&gt;

&lt;p&gt;Time the loop, not the request.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>agents</category>
      <category>python</category>
    </item>
    <item>
      <title>Building an offline-first React Native app with Turso Sync, Measure.sh and Claude Code</title>
      <dc:creator>Kathank Raithatha</dc:creator>
      <pubDate>Tue, 24 Nov 2026 14:56:34 +0000</pubDate>
      <link>https://dev.to/studio1hq/building-an-offline-first-react-native-app-with-turso-sync-measure-and-claude-code-fa5</link>
      <guid>https://dev.to/studio1hq/building-an-offline-first-react-native-app-with-turso-sync-measure-and-claude-code-fa5</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I built &lt;strong&gt;SyncNote&lt;/strong&gt;, an offline-first notes app in &lt;a href="https://reactnative.dev" rel="noopener noreferrer"&gt;React Native&lt;/a&gt; and &lt;a href="https://docs.expo.dev" rel="noopener noreferrer"&gt;Expo&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://docs.turso.tech/sync" rel="noopener noreferrer"&gt;Turso Sync&lt;/a&gt;&lt;/strong&gt; stores the notes in a local database on the phone and syncs it with the cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://measure.sh" rel="noopener noreferrer"&gt;Measure&lt;/a&gt;&lt;/strong&gt; adds mobile observability: events, traces, errors, network calls and bug reports from the device.&lt;/li&gt;
&lt;li&gt;When a sync failed, &lt;strong&gt;&lt;a href="https://claude.com/claude-code" rel="noopener noreferrer"&gt;Claude Code&lt;/a&gt;&lt;/strong&gt; used the &lt;strong&gt;&lt;a href="https://measure.sh/docs/mcp" rel="noopener noreferrer"&gt;Measure MCP server&lt;/a&gt;&lt;/strong&gt; to read the session and find the cause.&lt;/li&gt;
&lt;li&gt;All numbers and screenshots come from a real run on an Android emulator.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What an offline-first app has to get right
&lt;/h2&gt;

&lt;p&gt;SyncNote is a notes app for teams that work without a reliable connection. Field technicians on a site visit. Consultants writing notes on a flight. Anyone editing a shared doc on a train.&lt;/p&gt;

&lt;p&gt;For the engineering team, that turns into four requirements:&lt;/p&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;What goes wrong without it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Saves work offline and survive an app kill&lt;/td&gt;
&lt;td&gt;Users lose edits when a save waits on the network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Changes from other devices arrive quickly&lt;/td&gt;
&lt;td&gt;Users edit an old version of the note&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The UI stays fast on a bad network&lt;/td&gt;
&lt;td&gt;A slow sync blocks typing and saving&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Two edits to the same note are handled&lt;/td&gt;
&lt;td&gt;One edit is overwritten and nobody knows&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Turso Sync covers the data side of the first three. The fourth needs app logic.&lt;/p&gt;

&lt;p&gt;There's a fifth problem that doesn't fit in the table. Once the app ships, it runs on phones you don't control. Different models, Android versions and networks. On a backend, you have logs and metrics on servers you own. On mobile, when sync breaks on a user's phone, you usually get a one-line support ticket and nothing else.&lt;/p&gt;

&lt;p&gt;Offline-first makes this harder. A failure can happen on a plane and only show up hours later, when the phone reconnects. And most sync problems don't crash the app, so crash reporting alone won't catch them. You need a record of the session: what the user did, whether the phone was online, and what each sync attempt did.&lt;/p&gt;

&lt;p&gt;That's the part Measure handles in this app.&lt;/p&gt;

&lt;h2&gt;
  
  
  The stack
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://reactnative.dev" rel="noopener noreferrer"&gt;React Native&lt;/a&gt; + &lt;a href="https://docs.expo.dev" rel="noopener noreferrer"&gt;Expo&lt;/a&gt; (SDK 58)&lt;/strong&gt;: the app, written in TypeScript and run as a development build.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://turso.tech/blog/react-native-bindings-for-turso" rel="noopener noreferrer"&gt;Turso Sync&lt;/a&gt;&lt;/strong&gt; : a local SQLite database on the device that syncs with Turso Cloud.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://measure.sh/docs/getting-started/react-native" rel="noopener noreferrer"&gt;Measure&lt;/a&gt;&lt;/strong&gt; : open-source mobile observability, added through an Expo config plugin.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://github.com/react-native-netinfo/react-native-netinfo" rel="noopener noreferrer"&gt;NetInfo&lt;/a&gt;&lt;/strong&gt;: tells the app when the device goes online or offline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a href="https://claude.com/claude-code" rel="noopener noreferrer"&gt;Claude Code&lt;/a&gt;&lt;/strong&gt; with the &lt;strong&gt;&lt;a href="https://measure.sh/docs/mcp" rel="noopener noreferrer"&gt;Measure MCP server&lt;/a&gt;&lt;/strong&gt;: reads production data and helps debug it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both SDKs include native code, so Expo Go can't run them. You need a &lt;a href="https://docs.expo.dev/develop/development-builds/introduction/" rel="noopener noreferrer"&gt;development build&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt;  &lt;code&gt;EXPO_PUBLIC_*&lt;/code&gt; values are bundled into the app, so this demo ships a Turso auth token inside the client. Don't do that in production. Issue short-lived tokens from your backend instead.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw6nb2t66nwv53oa9n5nd.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fw6nb2t66nwv53oa9n5nd.png" alt="How SyncNote is wired: the phone holds the UI, the local database, the sync engine and the Measure SDK. Turso Cloud and a laptop sit on one side, Measure and Claude Code on the other." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The app only reads and writes the local database. Sync, telemetry and debugging happen around it.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Storing data on the device with Turso Sync
&lt;/h2&gt;

&lt;p&gt;Turso Sync gives each device its own local database file. The app reads and writes that file, and syncs it with Turso Cloud when a connection is available. That is the model I wanted, so the whole data layer is one file on the phone.&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;// src/db.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getDbPath&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@tursodatabase/sync-react-native'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nf"&gt;getDbPath&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'syncnote.db'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;        &lt;span class="c1"&gt;// SQLite file on the device&lt;/span&gt;
  &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;EXPO_PUBLIC_TURSO_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// libsql://&amp;lt;db&amp;gt;.turso.io&lt;/span&gt;
  &lt;span class="n"&gt;authToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;EXPO_PUBLIC_TURSO_AUTH_TOKEN&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;clientName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`syncnote-${deviceId}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;bootstrapIfEmpty&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;// first launch downloads the DB once&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;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;connect&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;Saving a note is a normal local write. It works the same on Wi-Fi, on 2G and in airplane mode. There is no loading spinner and no separate offline mode.&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;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="s1"&gt;'UPDATE notes SET title = ?, content = ?, rev = ?, updated_at = ?, updated_by = ? WHERE id = ?'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&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="n"&gt;deviceId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;id&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;Syncing is two calls:&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;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&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="c1"&gt;// send local changes to Turso Cloud&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;changed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pull&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="c1"&gt;// apply changes from other devices&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;stats&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stats&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="c1"&gt;// pending changes, last pull time, bytes&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The app syncs after each save when online, and again when the device reconnects. While the app is open, it also pulls every 5 seconds. In my test, a laptop edit showed up on the phone in &lt;strong&gt;about 4.4 seconds&lt;/strong&gt;. Most of that was waiting for the next 5-second poll. The pull itself took &lt;strong&gt;345 ms&lt;/strong&gt; and downloaded &lt;strong&gt;about 4 KB&lt;/strong&gt;. Turso also supports long polling on pull (&lt;code&gt;longPollTimeoutMs&lt;/code&gt;), which I didn't try here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Handling two edits to the same note
&lt;/h2&gt;

&lt;p&gt;Turso Sync resolves conflicts with &lt;strong&gt;last push wins&lt;/strong&gt;. If two devices change the same row, the server keeps whichever push &lt;a href="https://docs.turso.tech/sync/conflict-resolution" rel="noopener noreferrer"&gt;arrives last&lt;/a&gt;. On pull, Turso rolls back your unpushed changes, applies the remote ones, and replays yours on top.&lt;/p&gt;

&lt;p&gt;That is a reasonable default, and many apps can live with it. For shared notes, I wanted users to know when it happens. If I edit a note offline and a teammate edits it online, one edit gets overwritten and the app never hears about it.&lt;/p&gt;

&lt;p&gt;So I added a revision check before each push:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Every note has a &lt;code&gt;rev&lt;/code&gt; number.&lt;/li&gt;
&lt;li&gt;The first offline edit stores the &lt;code&gt;base_rev&lt;/code&gt; it started from.&lt;/li&gt;
&lt;li&gt;Before pushing, the app asks Turso Cloud which revision the server has.&lt;/li&gt;
&lt;li&gt;If the server is ahead of &lt;code&gt;base_rev&lt;/code&gt;, the app stops the push and shows both versions.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/store.tsx (simplified)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;remote&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchRemoteNotes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;pendingUpdates&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;note_id&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;conflicts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pendingUpdates&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&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="n"&gt;remote&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="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;note_id&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rev&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;base_rev&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="n"&gt;conflicts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sync_conflict_detected'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;note_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base_rev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remote_rev&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;remote_updated_by&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;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;SyncConflictError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;conflicts&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// nothing is pushed&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&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;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pull&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;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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp0nv42wofemh2xr0bt5v.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp0nv42wofemh2xr0bt5v.png" alt="What happens when the phone reconnects: reconnect, ask the server for its revision, then push and pull. The red branch shows the conflict path." width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Turso handles push and pull. The revision check between them is app code.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To be clear about the split: storage, sync and conflict resolution come from Turso. The revision check and the "Keep mine / Use theirs" screen are my code.&lt;/p&gt;

&lt;p&gt;The check has one gap. It runs before &lt;code&gt;push()&lt;/code&gt;, not inside it. If another device writes in the short window between the check and the push, last push wins still applies. That was fine for a demo, but worth knowing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding mobile observability with Measure
&lt;/h2&gt;

&lt;p&gt;Sync bugs happen on users' phones, on networks I can't reproduce at my end. To see them, I used &lt;a href="https://measure.sh" rel="noopener noreferrer"&gt;Measure&lt;/a&gt;, an open-source mobile observability platform. You can self-host it.&lt;/p&gt;

&lt;p&gt;Measure captures crashes and ANRs automatically. For this project, the more useful part was the session timeline. It shows screens, taps, network calls, logs and my own events in order. Sync problems rarely crash the app, so crash reporting alone would miss them.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup
&lt;/h3&gt;

&lt;p&gt;Measure ships an Expo config plugin:&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;// app.config.ts&lt;/span&gt;
&lt;span class="n"&gt;plugins&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="s1"&gt;'@measuresh/react-native'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;androidApiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;androidApiUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_URL&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;iosApiKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_KEY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;iosApiUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;MEASURE_API_URL&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="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/telemetry.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MeasureConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@measuresh/react-native'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;MeasureConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;enableLogging&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;__DEV__&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On Android, the plugin also adds Measure's OkHttp interceptor. Without it, &lt;a href="https://measure.sh/docs/network-monitoring" rel="noopener noreferrer"&gt;network monitoring&lt;/a&gt; doesn't capture HTTP calls.&lt;/p&gt;

&lt;h3&gt;
  
  
  What I track
&lt;/h3&gt;

&lt;p&gt;All tracking code is in one file, &lt;code&gt;src/telemetry.ts&lt;/code&gt;. It never sends note text. Only ids, revision numbers, lengths, counts and timings.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Events&lt;/strong&gt; mark each step of a sync:&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="nf"&gt;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'note_saved_locally'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;note_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;is_online&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;local_write_ms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;41.1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;base_rev&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&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;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'connectivity_changed'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;is_online&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="n"&gt;connection_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cellular'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;offline_duration_ms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;33324&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;track&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sync_started'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;trigger&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'reconnect'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;turso_cdc_operations&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;replica_last_pull_age_ms&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;84526&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;The last two fields in &lt;code&gt;sync_started&lt;/code&gt; come from Turso's &lt;code&gt;stats()&lt;/code&gt;. They show how many changes were waiting, and how long since the device last pulled. When debugging the conflict later, &lt;code&gt;turso_cdc_operations: 1&lt;/code&gt; confirmed there was exactly one unpushed change.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;local_write_ms&lt;/code&gt; measures my whole save function, not just Turso's write. It includes a read, the write, and a second write to a local-only queue table, all in a debug build. So treat it as an upper bound for the app, not a Turso benchmark.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Traces&lt;/strong&gt; time each sync. These are app-side &lt;a href="https://measure.sh/docs/performance-tracing" rel="noopener noreferrer"&gt;spans&lt;/a&gt; that wrap my calls to the Turso SDK. They are not Turso's internal traces. Each sync is a &lt;code&gt;sync&lt;/code&gt; trace with one child span per phase:&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startSpan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'sync'&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;push&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startSpan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'sync.push'&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;setParent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;notesDb&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&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="n"&gt;push&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SpanStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&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="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;SpanStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;end&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;In my test sessions, &lt;code&gt;sync.live_pull&lt;/code&gt; took &lt;strong&gt;259 ms at p50&lt;/strong&gt; and &lt;strong&gt;1.3 s at p95&lt;/strong&gt;. A full &lt;code&gt;sync&lt;/code&gt; took &lt;strong&gt;2.26 s at p50&lt;/strong&gt;. That's from a handful of runs on one emulator, so read it as a sanity check, not a benchmark.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Handled errors&lt;/strong&gt; carry context about where the sync failed:&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="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trackError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;phase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'push'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;reason&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'network'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;connection_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'cellular'&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;Measure &lt;a href="https://measure.sh/docs/error-monitoring/grouping" rel="noopener noreferrer"&gt;groups errors&lt;/a&gt; by type, message and top stack frame. Conflicts, slow syncs and network failures each got their own group.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://measure.sh/docs/adaptive-capture" rel="noopener noreferrer"&gt;Measure samples&lt;/a&gt; handled errors at 0% by default. I ran this demo with full collection on. In production, raise the rate for the errors you care about.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Network calls&lt;/strong&gt; need no extra code. The Turso SDK makes HTTP requests from the app, and Measure records them on the session timeline with status codes and durations. &lt;code&gt;POST /pull-updates&lt;/code&gt; is Turso's pull. &lt;code&gt;POST /v2/pipeline&lt;/code&gt; is used by Turso's push and also by my revision check. Measure &lt;a href="https://measure.sh/docs/adaptive-capture#blocked-headers" rel="noopener noreferrer"&gt;never collects&lt;/a&gt; the &lt;code&gt;Authorization&lt;/code&gt; header. I checked the raw session data, and the Turso token was not there.&lt;/p&gt;

&lt;h3&gt;
  
  
  Bug reports from users
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launchBugReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;takeScreenshot&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="n"&gt;attributes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pending_count&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sync_status&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="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;onShake&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;handler&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Measure&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;launchBugReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;takeScreenshot&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="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;A &lt;a href="https://measure.sh/docs/bug-reports" rel="noopener noreferrer"&gt;bug report&lt;/a&gt; opens a native screen with a screenshot attached. Text in the screenshot is masked by default. The report is linked to the session, so you can replay what happened before it.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frk1evrxchd67850uifls.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frk1evrxchd67850uifls.png" alt="Measure's in-app bug report screen on React Native, with the attached screenshot masked" width="800" height="1422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The bug report screen. Note text in the screenshot is masked.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing four scenarios on an Android emulator
&lt;/h2&gt;

&lt;p&gt;I ran these tests on an Android 12 (API 31) emulator, with a Turso Cloud database and Measure. It was a debug build.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Saving while offline
&lt;/h3&gt;

&lt;p&gt;I turned on airplane mode, edited a note and saved it. Then I force-killed the app and opened it again, still offline.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F94wq5l8wkx22ayguly2i.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F94wq5l8wkx22ayguly2i.png" alt="The note editor showing &amp;quot;Saved on this device, will sync when online&amp;quot; while offline" width="800" height="1422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Saved offline. The sync status shows Pending.&lt;/em&gt;&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu741wcbci1vdzjr2gj54.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fu741wcbci1vdzjr2gj54.png" alt="The notes list after reopening the app offline, with the edit still there" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After a force-kill and reopen, the edit is still there.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The edit survived the restart. In Measure, the session shows &lt;code&gt;note_saved_locally&lt;/code&gt; with &lt;code&gt;is_online: false&lt;/code&gt; and &lt;code&gt;local_write_ms: 45.5&lt;/code&gt;. Then &lt;code&gt;app_opened&lt;/code&gt; with one pending change.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. An edit from another device
&lt;/h3&gt;

&lt;p&gt;With the phone online, a second client edited the same note in Turso Cloud. I used a Node script to act as the laptop. The server saved the change at &lt;code&gt;00:40:40.7&lt;/code&gt;. The phone showed it at &lt;code&gt;00:40:45.1&lt;/code&gt;.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F11339lmcihsw4aa3fjso.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F11339lmcihsw4aa3fjso.png" alt="The notes list with a badge reading &amp;quot;Updated from laptop-web-client&amp;quot;" width="800" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The next pull brought the change in 345 ms, using 4,165 bytes.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. A slow network
&lt;/h3&gt;

&lt;p&gt;I throttled the emulator to GSM speed with GPRS latency, and turned Wi-Fi off so the limit applied.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3j1c2a28yz36r4g4hvhw.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3j1c2a28yz36r4g4hvhw.png" alt="The editor showing &amp;quot;Saved&amp;quot; while the sync status still says &amp;quot;Syncing&amp;quot;" width="800" height="1422"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Saved in 41 ms, while sync is still running.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Saving was instant but Sync failed. Measure recorded each step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SlowSyncError&lt;/code&gt; when the push passed the app's own 8-second budget&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;java.io.IOException: unexpected end of stream&lt;/code&gt; from the push request, after 31.5 s. The throttled connection dropped, and the Turso SDK passed the network error up to the app. The app logged it as &lt;code&gt;sync_failed&lt;/code&gt; with &lt;code&gt;phase: push&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;sync_completed&lt;/code&gt; that took 66.9 s once the edit finally synced&lt;/li&gt;
&lt;/ul&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtcmc4qeq2506bdm532q.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fvtcmc4qeq2506bdm532q.png" alt="Bar chart: a 41 ms local save next to a 66.9 second sync on a throttled network" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Same app on the same emulator. Only the network changed.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The app never crashed, so crash reporting would show nothing here. The traces and handled errors are what made the slow sync visible.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Two people editing the same note
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;On the phone, offline, I edited the note. The edit started from &lt;strong&gt;rev 6&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;On the laptop, a second edit moved the server to &lt;strong&gt;rev 7&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;The phone reconnected and started syncing.&lt;/li&gt;
&lt;/ol&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftgw1qzvazvdyy0gfdn2q.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftgw1qzvazvdyy0gfdn2q.png" alt="The notes list with a &amp;quot;Sync conflict&amp;quot; banner after reconnecting" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The conflict is detected on reconnect.&lt;/em&gt;&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fps6wvf1wjwnkqwac97w5.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fps6wvf1wjwnkqwac97w5.png" alt="The conflict card showing both versions of the note, with Keep mine and Use theirs buttons" width="800" height="963"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Both versions are shown, and the user picks one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The revision check stopped the push about &lt;strong&gt;2 seconds&lt;/strong&gt; after reconnecting. The sync itself ran for 1.3 s before it failed. Without the check, the laptop's edit would have been overwritten.&lt;/p&gt;

&lt;p&gt;Next, I filed a bug report from the app: &lt;em&gt;"Edited Launch Plan on the plane. After landing it says sync conflict. Which version is right?"&lt;/em&gt; Then I tapped Keep mine. The server ended at rev 8 with the phone's text.&lt;/p&gt;

&lt;h2&gt;
  
  
  Debugging the sync failure with Claude Code and the Measure MCP server
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://measure.sh/docs/mcp" rel="noopener noreferrer"&gt;Measure MCP server&lt;/a&gt; lets coding agents query an app's sessions, errors, traces and bug reports. I connected it to Claude Code with this command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude mcp add --transport http measure https://agent.measure.sh/mcp
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then I gave this prompt to Claude Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A user filed a bug report about a sync conflict. Find it, analyze the session
timeline, connectivity changes, sync attempts and conflict events, identify
the root cause and suggest a fix.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjsjyrwohhxh5p73mf61k.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjsjyrwohhxh5p73mf61k.png" alt="The steps Claude Code took: find the bug report, open its session, read the errors, read the sync code, then explain the cause" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;The MCP calls Claude made, and the source file it read.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;It found the bug report, opened the linked session and rebuilt the timeline:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flw5adezkb5hhm3sz7mj4.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flw5adezkb5hhm3sz7mj4.png" alt="A timeline of one session: the app opens offline, comes back online 33 seconds after launch, conflict detected, bug report filed, then resolved and synced" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Each label is a real event from the session.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is a short version of its answer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What happened:&lt;/strong&gt; the session started offline with one unpushed change, and the phone reconnected 33 seconds later. That edit started from rev 6. While the phone was offline, the laptop saved rev 7. On reconnect, the revision check saw rev 7 and blocked the push.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Root cause:&lt;/strong&gt; two people edited the same note while one was offline. Turso Sync uses last push wins, and the app has no merge step. It can only ask the user to pick a version.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Suggested fixes:&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;Merge the two texts, using rev 6 as the common base (a three-way merge).&lt;/li&gt;
&lt;li&gt;Track revisions per paragraph instead of per note.&lt;/li&gt;
&lt;li&gt;Warn the user before editing if the note changed on another device.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I could check each point against an event, an error group or a line in &lt;code&gt;store.tsx&lt;/code&gt;. That works because the app logs revisions, device ids and Turso's stats, not just "sync failed".&lt;/p&gt;

&lt;p&gt;Claude also found an unhandled &lt;code&gt;ReferenceError&lt;/code&gt; in the error list. That was my bug. Fast Refresh had loaded a half-finished edit, and Measure caught the error with no extra setup.&lt;/p&gt;

&lt;p&gt;Finally, I asked Claude to create a &lt;a href="https://measure.sh/docs/funnels" rel="noopener noreferrer"&gt;funnel&lt;/a&gt; through the MCP server: &lt;code&gt;note_saved_locally → connectivity_changed → sync_started → sync_failed → conflict_resolved → sync_completed&lt;/code&gt;. With one test user, the time between steps was 51 s, 0.9 s, 1.3 s and 58 s. With real users, the medians would show how long people stay stuck on a conflict.&lt;/p&gt;

&lt;h2&gt;
  
  
  Results
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Measurement&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;App save function (debug build)&lt;/td&gt;
&lt;td&gt;41–46 ms&lt;/td&gt;
&lt;td&gt;&lt;code&gt;note_saved_locally&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Laptop edit visible on phone&lt;/td&gt;
&lt;td&gt;about 4.4 s (mostly the 5 s poll)&lt;/td&gt;
&lt;td&gt;wall clock&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Live pull&lt;/td&gt;
&lt;td&gt;p50 259 ms, p95 1.3 s&lt;/td&gt;
&lt;td&gt;Measure span metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sync on a normal network&lt;/td&gt;
&lt;td&gt;about 0.9–1.2 s&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sync_completed&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Sync on throttled GSM&lt;/td&gt;
&lt;td&gt;failed at 31.5 s, succeeded at 66.9 s&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;sync_failed&lt;/code&gt;, &lt;code&gt;sync_completed&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Conflict detected after reconnect&lt;/td&gt;
&lt;td&gt;2.2 s (1.3 s into the sync)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;sync_failed&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Note text or auth token in telemetry&lt;/td&gt;
&lt;td&gt;none found&lt;/td&gt;
&lt;td&gt;raw session data&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you want to check the demo implementation, refer &lt;a href="https://github.com/Studio1HQ/turso_measure_demo" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Does Turso Sync work offline in React Native and Expo?
&lt;/h3&gt;

&lt;p&gt;Yes. The first launch needs a connection to download the database. After that, reads and writes go to a local file. Changes stay there until you call &lt;code&gt;push()&lt;/code&gt;. You need an Expo development build, not Expo Go.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Turso Sync handle conflicts?
&lt;/h3&gt;

&lt;p&gt;With &lt;a href="https://docs.turso.tech/sync/conflict-resolution" rel="noopener noreferrer"&gt;last push wins&lt;/a&gt;. On pull, unpushed local changes are rolled back, remote changes are applied, and local changes are replayed on top. The React Native package I used (0.8.3) doesn't expose a conflict hook. So to detect concurrent edits, I added a version column and checked it before pushing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I use Measure with Expo?
&lt;/h3&gt;

&lt;p&gt;Yes. The &lt;a href="https://measure.sh/docs/getting-started/react-native" rel="noopener noreferrer"&gt;&lt;code&gt;@measuresh/react-native&lt;/code&gt;&lt;/a&gt; package includes an Expo config plugin. It sets your API keys, starts the native SDKs and enables HTTP capture on Android.&lt;/p&gt;

&lt;h3&gt;
  
  
  How does Measure compare to Firebase Crashlytics or Sentry for React Native?
&lt;/h3&gt;

&lt;p&gt;All three report crashes and Android ANRs. Crashlytics only reports ANRs from Android 11 and later. The differences are elsewhere:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Network calls.&lt;/strong&gt; Measure and Sentry capture HTTP requests automatically. Crashlytics doesn't. That needs Firebase Performance Monitoring, a separate product.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;User feedback.&lt;/strong&gt; Measure and Sentry both have an in-app bug report with screenshots. I couldn't find an equivalent in Crashlytics.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hosting.&lt;/strong&gt; Measure is open source under Apache 2.0 and can be self-hosted. Sentry can also be self-hosted, under its Functional Source License. Crashlytics runs on Google's servers only.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;React Native SDK.&lt;/strong&gt; Measure and Sentry maintain their own React Native SDKs. The Crashlytics package for React Native (&lt;code&gt;@react-native-firebase/crashlytics&lt;/code&gt;) is maintained by Invertase, not Google.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of them runs fully in Expo Go. All three use a config plugin and a development build. For this project I picked Measure because I wanted open source with a self-host option, and a session timeline with my own events on it.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does the Measure MCP server do?
&lt;/h3&gt;

&lt;p&gt;Measure &lt;a href="https://measure.sh/docs/mcp" rel="noopener noreferrer"&gt;MCP Server&lt;/a&gt; lets AI coding agents like Claude Code, Cursor and Codex query your app's errors, sessions, traces, bug reports and funnels. The agent works from what happened on real devices, so it doesn't have to guess. Sentry and Firebase have MCP servers too, so this way of working isn't tied to one vendor.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;If you love my content ❤️ Follow me on &lt;a href="https://www.linkedin.com/in/kathank/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt;&lt;br&gt;
~ Kathank Raithatha&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>database</category>
      <category>mobile</category>
      <category>reactnative</category>
    </item>
    <item>
      <title>A release checklist for mobile apps built with AI coding agents🔥</title>
      <dc:creator>Astrodevil</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:33:54 +0000</pubDate>
      <link>https://dev.to/studio1hq/a-release-checklist-for-mobile-apps-built-with-ai-coding-agents-5bn4</link>
      <guid>https://dev.to/studio1hq/a-release-checklist-for-mobile-apps-built-with-ai-coding-agents-5bn4</guid>
      <description>&lt;p&gt;Coding agents can now test their own code changes. They build the app, open it on a simulator, tap through the new screen and attach screenshots to the pull request.&lt;/p&gt;

&lt;p&gt;This is already happening. On 19 November 2026, Expo shared &lt;a href="https://expo.dev/blog/agentic-workflows-with-expo-simulators" rel="noopener noreferrer"&gt;Agentic Workflows with Expo Simulators&lt;/a&gt;. In it, an agent runs your app on a cloud iOS simulator or Android emulator and posts what it saw on the PR. Callstack built a &lt;a href="https://www.callstack.com/blog/building-reviewable-mobile-qa-agents-with-vercel-eve" rel="noopener noreferrer"&gt;sample QA agent&lt;/a&gt; that reads the PR, decides what to test and comments the results on GitHub. Flutter's &lt;a href="https://docs.flutter.dev/ai/get-started" rel="noopener noreferrer"&gt;AI setup guide&lt;/a&gt; connects Claude Code, Codex, Cursor and others to the Dart analyzer, the test runner and the running app.&lt;/p&gt;

&lt;p&gt;That's useful. But a passing run only tells you about one build, on one device, along one path. It doesn't tell you what happens when someone upgrades from the old version, denies a permission, loses network mid-upload, or comes back to an app that Android killed in the background.&lt;/p&gt;

&lt;p&gt;Below is a checklist for those gaps, built around one example. It works for React Native, Flutter, Expo and native apps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tl;dr
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A passing agent run covers one build, one device and one path. Say in the PR what it didn't test.&lt;/li&gt;
&lt;li&gt;Test the release build, not the debug build.&lt;/li&gt;
&lt;li&gt;Pick test devices and scenarios based on what the change could break. Android process death and app upgrades are easy to miss.&lt;/li&gt;
&lt;li&gt;Make sure every crash report shows which build it came from. Send a test error before release to check.&lt;/li&gt;
&lt;li&gt;Stopping a staged rollout doesn't remove the update from phones that already have it. On iOS, pausing only stops automatic updates.&lt;/li&gt;
&lt;li&gt;Decide before launch what numbers would make you pause. Then compare the new version with the old one, by device and OS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The example: photo upload in an expense app
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frqax8o58wzq0h3v8wv7j.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frqax8o58wzq0h3v8wv7j.png" alt="What the agent's run actually covered: one happy path, with untested branches for permission denial, process death, network loss, backgrounding and upgrades" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Say a coding agent adds receipt photo upload to an expense app. The app opens the phone's camera app, uploads the photo and saves unsent receipts as drafts. The agent tests it on an Android emulator. It takes a photo with the emulator's camera, sees the upload work and attaches four screenshots to the PR.&lt;/p&gt;

&lt;p&gt;Everything in that report can be correct, and the feature can still break for real users.&lt;/p&gt;

&lt;p&gt;Here is one way. When your app opens another app and waits for a result, Android may kill your app's process to free memory. This is "almost certain" for "memory-intensive operations such as camera usage" for &lt;a href="https://developer.android.com/training/basics/intents/result" rel="noopener noreferrer"&gt;Android&lt;/a&gt;. So on a low-memory phone, the user takes the photo, comes back, and your app has to rebuild the screen and the draft from saved state. An emulator with lots of memory rarely does this, so the agent never sees it.&lt;/p&gt;

&lt;p&gt;You can test it yourself. Open the camera from your app, then run &lt;em&gt;adb shell am kill&lt;/em&gt; with your package name. Go back to the app and check that the photo and the draft are still there.&lt;/p&gt;

&lt;p&gt;The same goes for a user who denies camera access, loses signal halfway through an upload, or updates from last month's version with unsent drafts saved.&lt;/p&gt;

&lt;p&gt;The agent's report isn't wrong. It just didn't test these cases, and the PR should say so.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give the agent a release brief
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9qoy6z5xppo6nv47idpc.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9qoy6z5xppo6nv47idpc.png" alt="A release brief goes to the coding agent, which returns a report with each check passed, failed or untested; failed or untested checks loop back to fix and rerun" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Before the agent tests anything, tell it which conditions matter. For the photo upload, that means permissions, network, the app going to the background, and data already saved on the phone. Then ask it to report on each one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Review the changed mobile flow for release readiness.
List assumptions about permissions, persisted data, network access,
native dependencies, and background/foreground transitions.

For each relevant assumption:
- propose a test with an observable expected result;
- identify the build and environment it needs;
- report whether it ran, failed, passed, or remains untested.

Do not treat an unexecuted test plan as a passing result.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An agent can write a good test plan and then call it done. Ask for a reason next to anything it didn't test.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Test on a release build&lt;/strong&gt;
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9r0rnqwe1lt6pvio7t7.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fl9r0rnqwe1lt6pvio7t7.png" alt="Development, profile and release builds, plus how Expo over-the-air updates apply only to a matching runtime version" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Debug builds and release builds behave differently, so test the one you want to ship for users.&lt;/p&gt;

&lt;p&gt;In React Native, &lt;a href="https://reactnative.dev/docs/performance" rel="noopener noreferrer"&gt;JavaScript runs much slower in dev mode&lt;/a&gt;, and the Dev Menu, LogBox and DevTools are &lt;a href="https://reactnative.dev/docs/debugging" rel="noopener noreferrer"&gt;turned off in release builds&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Flutter &lt;a href="https://docs.flutter.dev/perf/ui-performance" rel="noopener noreferrer"&gt;recommends&lt;/a&gt; checking performance in profile mode on a real device, ideally the slowest one your users might have.&lt;/p&gt;

&lt;p&gt;With Expo, an over-the-air update only works on builds with matching native code. Expo tracks this with the &lt;a href="https://docs.expo.dev/eas-update/runtime-versions/" rel="noopener noreferrer"&gt;runtime version&lt;/a&gt;. If your change adds native code, like a new camera library, you need a new build and a store review.&lt;/p&gt;

&lt;p&gt;Also test an upgrade, not just a fresh install. A fresh install starts with an empty database, so it never runs your database migrations.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Pick your test devices and cases&lt;/strong&gt;
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcx89yb6d7nzo7ca5crf9.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcx89yb6d7nzo7ca5crf9.png" alt="Example test matrix for the photo upload change across low-RAM Android, popular Android, oldest supported iPhone and current iPhone" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start with the devices and OS versions your users actually have. Include at least one low-memory Android phone. It's the one most likely to kill your app while the camera is open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For the photo upload, test these&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deny camera permission. Also allow it, then turn it off in Settings.&lt;/li&gt;
&lt;li&gt;Turn off the network during an upload. Check that it recovers.&lt;/li&gt;
&lt;li&gt;Send the app to the background during an upload, then come back.&lt;/li&gt;
&lt;li&gt;On Android, come back after the system killed the app. A ViewModel survives screen rotation but not &lt;a href="https://developer.android.com/topic/libraries/architecture/saving-states" rel="noopener noreferrer"&gt;process death&lt;/a&gt;, so keep important state in saved state or storage.&lt;/li&gt;
&lt;li&gt;Update from the previous version with unsent drafts on the phone.&lt;/li&gt;
&lt;li&gt;Open a link to the receipt screen when the app is closed and when it's already open.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Agents can now run many of these for you. &lt;a href="https://github.com/callstack/agent-device" rel="noopener noreferrer"&gt;Callstack's agent-device&lt;/a&gt; lets coding agents control apps on iOS and Android simulators, emulators and real devices. &lt;a href="https://docs.maestro.dev/" rel="noopener noreferrer"&gt;Maestro&lt;/a&gt; runs repeatable UI tests on Android devices and iOS simulators.&lt;/p&gt;

&lt;p&gt;Write down exactly where each test ran. "Passed on one Android emulator" is useful. "Works on Android" is not.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Get crash reporting ready before release&lt;/strong&gt;
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj0dv6z99ktiec6wcv2n0.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj0dv6z99ktiec6wcv2n0.png" alt="The same Android crash with and without the mapping file, a timeline of outcome events, and a three-step telemetry check before release" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once users have the update, you need to know which build each crash came from. Keep the app version, build number and commit together in your release pipeline. If you ship over-the-air updates, add the runtime version and update ID.&lt;/p&gt;

&lt;p&gt;Upload the dSYMs, Android mapping files and JavaScript source maps for each build. Without them, crash reports show unreadable stack traces instead of your code.&lt;/p&gt;

&lt;p&gt;Track the result the user cares about. "The receipt appeared in the list" tells you more than "the request returned 200". A loading spinner on screen doesn't mean the job is done.&lt;/p&gt;

&lt;p&gt;Before release, send a test error from a test build. Check that it shows up with the right build number, then remove it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What staged rollouts can and can't do
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjlro2y8du9ku78j6pc27.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fjlro2y8du9ku78j6pc27.png" alt="Google Play staged rollout halted at 20 percent next to the App Store 7-day phased release schedule" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;On Google Play, &lt;a href="https://support.google.com/googleplay/android-developer/answer/6346149?hl=en" rel="noopener noreferrer"&gt;staged rollouts&lt;/a&gt; only work for updates, not for an app's first release. You raise the percentage yourself. If you halt a rollout, new users stop getting the update, but people who already have it keep it. You can resume later. To undo a bad update, you have to ship a new one.&lt;/p&gt;

&lt;p&gt;On the App Store, a &lt;a href="https://developer.apple.com/help/app-store-connect/update-your-app/release-a-version-update-in-phases/" rel="noopener noreferrer"&gt;phased release&lt;/a&gt; takes 7 days: 1%, 2%, 5%, 10%, 20%, 50%, then 100% of users with automatic updates on. Anyone can still update by hand at any time. Pausing only stops the automatic updates, and you can pause for up to 30 days in total.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So on iOS, a 1% day doesn't mean only 1% of users can get the bug. For a first release, use a testing track or TestFlight instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Watch the rollout in production
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbw1pqhx1toeonhsfc9q6.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbw1pqhx1toeonhsfc9q6.png" alt="Illustrative chart of crash-free sessions by phone model for the new and old version, and the three outcomes: pause, hold or expand" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On day one, you want to know if 4.12.0 crashes or hits more ANRs or app hangs than 4.11.0, especially on low-memory phones. &lt;a href="https://measure.sh/" rel="noopener noreferrer"&gt;Measure&lt;/a&gt; helps you answer that. It records crashes, ANRs, traces and session replay for each session in one timeline. It's open source, you can host it yourself, and it has SDKs for Android, iOS, Flutter, React Native and Kotlin Multiplatform.&lt;/p&gt;

&lt;p&gt;Compare the new version with the old one over the same time period. Look at crash-free sessions, ANR-free sessions, cold start time (p95) and how often users finish the changed flow. Then break it down by phone model and OS version. The average can look fine while one phone model fails many uploads.&lt;/p&gt;

&lt;p&gt;You can also ask an agent. &lt;a href="https://measure.sh/docs/agent" rel="noopener noreferrer"&gt;Measure Agent&lt;/a&gt; answers natural language questions about your crashes, errors, sessions, traces and metrics. It can compare versions and time ranges. You can ask it in Slack, or from Claude Code, Codex or Cursor through &lt;a href="https://measure.sh/docs/mcp" rel="noopener noreferrer"&gt;Measure's MCP server&lt;/a&gt;. The MCP server can also fetch the sessions behind an answer, so you can check them yourself. Ask the agent to tell you what data it didn't have, like a device group that hasn't received the update yet.&lt;/p&gt;

&lt;p&gt;If you need more detail during the rollout, &lt;a href="https://measure.sh/docs/adaptive-capture" rel="noopener noreferrer"&gt;Adaptive Capture&lt;/a&gt; lets you change sampling and session replay settings without a new release. A change takes effect on the second app launch, so give it some time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Decide when to pause
&lt;/h2&gt;

&lt;p&gt;Decide before the rollout what would make you stop. For example: a new crash in a key flow, slower response times, or fewer users finishing the changed flow. Base these limits on your own normal numbers.&lt;/p&gt;

&lt;p&gt;Google Play has its own limits in &lt;a href="https://developer.android.com/topic/performance/vitals" rel="noopener noreferrer"&gt;Android vitals&lt;/a&gt;. Play flags an app when more than 1.09% of daily users see a crash, or more than 0.47% see an ANR, across all devices. On a single phone model, the limit is 8%. Play looks at the last 28 days, and going over can hurt your store visibility. Your own limits for an important flow should be much stricter.&lt;/p&gt;

&lt;p&gt;Check that both versions use the same sampling, so you compare fair numbers.&lt;/p&gt;

&lt;p&gt;Decide who is allowed to pause the release, and how you'll help users who already have the bad build.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep user data out of logs and prompts
&lt;/h2&gt;

&lt;p&gt;Monitoring a release shouldn't mean copying customer data into logs or AI prompts.&lt;/p&gt;

&lt;p&gt;In Measure, screenshots on crashes and bug reports are optional, and sensitive content is &lt;a href="https://measure.sh/docs/error-monitoring/screenshot-masking" rel="noopener noreferrer"&gt;masked on the device&lt;/a&gt; before upload. On iOS, SwiftUI screens are fully masked by default. In Flutter, custom-drawn content needs a mask widget. Request and response bodies and headers are only &lt;a href="https://measure.sh/docs/network-monitoring" rel="noopener noreferrer"&gt;collected for URLs you choose&lt;/a&gt;, and headers like Authorization and Cookie are always blocked. You still need to review your own custom events.&lt;/p&gt;

&lt;p&gt;If you host Measure yourself, its &lt;a href="https://measure.sh/docs/hosting/agent" rel="noopener noreferrer"&gt;AI agent&lt;/a&gt; is off by default. When you turn it on, it sends prompts to a language model through OpenRouter. Any outside coding agent you connect handles data in its own way.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the pieces fit together
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F30h621ps0bbzpoxzihf5.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F30h621ps0bbzpoxzihf5.png" alt="The AI-assisted release loop: coding agent, device checks, review, limited rollout, production monitoring, and the agent reading production data for the next change" width="720" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After release, Measure shows what happened in which build, on which devices and in which sessions. Through MCP, the same coding agent that wrote the change can read that data when you start the next change.&lt;/p&gt;

&lt;h2&gt;
  
  
  A release record to copy
&lt;/h2&gt;

&lt;p&gt;Add a short record to the PR for each release:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Build:&lt;/strong&gt; version, build number, commit, runtime version and update ID&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tested:&lt;/strong&gt; each check, with the device, OS version and result&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Not tested:&lt;/strong&gt; what nobody checked, and why&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Monitoring:&lt;/strong&gt; test error received with the right build ID, symbols uploaded&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rollout:&lt;/strong&gt; store, percentage, start date and number of users&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Decision:&lt;/strong&gt; expand, hold or pause, and the numbers behind it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next engineer, or the next agent, can start from there when something needs fixing.&lt;/p&gt;

&lt;p&gt;Measure is open source. To try it, start with the &lt;a href="https://measure.sh/docs" rel="noopener noreferrer"&gt;docs&lt;/a&gt; or the &lt;a href="https://github.com/measure-sh/measure" rel="noopener noreferrer"&gt;GitHub repo&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>mobile</category>
      <category>reactnative</category>
      <category>flutter</category>
    </item>
    <item>
      <title>DevRel vs Developer Marketing: What's the Difference and Why It Matters</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Sat, 21 Nov 2026 18:00:00 +0000</pubDate>
      <link>https://dev.to/studio1hq/devrel-vs-developer-marketing-whats-the-difference-and-why-it-matters-bd9</link>
      <guid>https://dev.to/studio1hq/devrel-vs-developer-marketing-whats-the-difference-and-why-it-matters-bd9</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;DevRel and developer marketing are often confused. The real differences, when to use each, and how the best developer teams combine both for growth.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you're building a developer product, you've probably heard both "DevRel" and "developer marketing" thrown around, sometimes interchangeably.&lt;/li&gt;
&lt;li&gt;They aren't the same thing, and treating them as one often leads to misallocated budgets, frustrated teams, and weak developer engagement.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're building a developer product, you've probably heard both "DevRel" and "developer marketing" thrown around, sometimes interchangeably. They aren't the same thing, and treating them as one often leads to misallocated budgets, frustrated teams, and weak developer engagement.&lt;/p&gt;

&lt;p&gt;Here's how they differ, where they overlap, and why the companies seeing real growth in 2026 are investing in both.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Developer Relations?
&lt;/h2&gt;

&lt;p&gt;Developer Relations (DevRel) is the practice of building genuine, long-term relationships with developers. It's bidirectional: DevRel teams represent the company to developers &lt;em&gt;and&lt;/em&gt; carry developer feedback back to product and engineering teams.&lt;/p&gt;

&lt;p&gt;Day-to-day work includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creating tutorials, guides, and documentation&lt;/li&gt;
&lt;li&gt;Speaking at conferences and meetups&lt;/li&gt;
&lt;li&gt;Managing community channels (Discord, GitHub Discussions, forums)&lt;/li&gt;
&lt;li&gt;Supporting developers through onboarding and debugging&lt;/li&gt;
&lt;li&gt;Advocating internally for developer experience improvements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 2026 Draft.dev Developer Marketing Survey found that &lt;strong&gt;73% of teams are increasing investment in community and events&lt;/strong&gt; this year, up from prior years. That reflects a broader recognition that trust-based relationships drive the most durable adoption.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Developer Marketing?
&lt;/h2&gt;

&lt;p&gt;Developer marketing uses structured campaigns and paid channels to reach developers with targeted messages. Think:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Paid search and social ads targeting technical audiences&lt;/li&gt;
&lt;li&gt;Newsletter and podcast sponsorships&lt;/li&gt;
&lt;li&gt;In-IDE advertising&lt;/li&gt;
&lt;li&gt;Landing pages optimized for developer sign-ups&lt;/li&gt;
&lt;li&gt;Retargeting campaigns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developer marketing delivers measurable reach quickly. You can test messaging, track conversions, and scale spend once you find what works.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Difference
&lt;/h2&gt;

&lt;p&gt;DevRel builds trust. Developer marketing builds awareness.&lt;/p&gt;

&lt;p&gt;DevRel is a long game. It typically takes six to twelve months before you can clearly attribute pipeline or adoption to community work. Developer marketing can show results in days or weeks, but it cannot replicate the organic word-of-mouth that a trusted community generates.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://survey.stackoverflow.co/2025/" rel="noopener noreferrer"&gt;Stack Overflow 2025 Developer Survey&lt;/a&gt; highlights this dynamic: when developers don't trust AI-generated answers, &lt;strong&gt;75% said they would ask another person&lt;/strong&gt; rather than rely on automated output. Developers value human expertise and peer recommendations over promotional messaging.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the Best Teams Combine Both
&lt;/h2&gt;

&lt;p&gt;The data from the 2026 Developer Marketing Survey makes the case:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;62%&lt;/strong&gt; of developer marketing teams are increasing budgets this year&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;64%&lt;/strong&gt; say community and events deliver their highest ROI&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;51%&lt;/strong&gt; are investing more in content marketing and SEO&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Companies that rely only on DevRel grow slowly. Companies that rely only on ads burn through budgets without building lasting loyalty. The winning pattern combines DevRel's authenticity with marketing's reach and measurement.&lt;/p&gt;

&lt;p&gt;Here's what that looks like in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;DevRel creates the substance.&lt;/strong&gt; Tutorials, open-source contributions, conference talks, and community support build credibility.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Marketing amplifies the substance.&lt;/strong&gt; Paid promotion, SEO, and distribution put that content in front of developers who haven't discovered the product yet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Both feed the product.&lt;/strong&gt; DevRel surfaces qualitative feedback ("this API is confusing"), marketing surfaces quantitative signals (which pages convert, which campaigns drive sign-ups).&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Common Mistakes
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Mistake 1: Calling it all "DevRel" when you mean marketing.&lt;/strong&gt; If your developer advocates are spending most of their time on campaign metrics and lead gen, you have a marketing team with a DevRel title. That's fine, but call it what it is so you can hire and measure correctly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 2: No measurement for DevRel.&lt;/strong&gt; DevRel is hard to measure, but "hard" doesn't mean "impossible." Track community growth, content engagement, support ticket volume, and developer NPS alongside traditional marketing KPIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mistake 3: Running ads before you have developer trust.&lt;/strong&gt; Paid campaigns pointing to a product with poor documentation, no community presence, and no social proof will underperform. Build the foundation first.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Decide What Your Team Needs
&lt;/h2&gt;

&lt;p&gt;Ask these questions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Do developers already know your product exists?&lt;/strong&gt; If not, marketing first to build awareness.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do developers try your product but churn quickly?&lt;/strong&gt; DevRel to improve onboarding, docs, and support.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do developers love your product but you can't scale word-of-mouth?&lt;/strong&gt; Marketing to amplify what's already working.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Are you pre-launch?&lt;/strong&gt; DevRel to build an early community and get feedback before you spend on acquisition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most developer-focused companies need both functions by the time they reach Series A. The question isn't "DevRel or marketing?" but "what ratio, and when?"&lt;/p&gt;

&lt;h2&gt;
  
  
  What We've Seen at Studio1
&lt;/h2&gt;

&lt;p&gt;We work with 35+ developer tool companies on &lt;a href="https://www.studio1hq.com/technical-content-marketing" rel="noopener noreferrer"&gt;technical content&lt;/a&gt; and &lt;a href="https://www.studio1hq.com/developer-relations-growth-campaigns" rel="noopener noreferrer"&gt;DevRel&lt;/a&gt;. The pattern is consistent: teams that invest in authentic technical content &lt;em&gt;and&lt;/em&gt; smart distribution outperform those that lean entirely on one side.&lt;/p&gt;

&lt;p&gt;The companies driving real developer adoption in 2026 aren't choosing between relationships and reach. They're building both.&lt;/p&gt;

</description>
      <category>product</category>
      <category>devrel</category>
      <category>development</category>
    </item>
    <item>
      <title>Why Software Companies Are Doubling Down on Content in 2026</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Sat, 21 Nov 2026 06:32:21 +0000</pubDate>
      <link>https://dev.to/studio1hq/why-software-companies-are-doubling-down-on-content-in-2026-40hl</link>
      <guid>https://dev.to/studio1hq/why-software-companies-are-doubling-down-on-content-in-2026-40hl</guid>
      <description>&lt;p&gt;Every software company says they want to "do content." Most underinvest, publish inconsistently, or chase vanity metrics. The companies that treat content as a core growth function, not an afterthought, are the ones winning developer attention and long-term adoption.&lt;/p&gt;

&lt;p&gt;Here's what the 2025 and 2026 research tells us, and what it means if you're building a developer product.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Numbers Are Clear
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://blog.hubspot.com/marketing/hubspot-blog-marketing-industry-trends-report" rel="noopener noreferrer"&gt;2026 HubSpot State of Marketing Report&lt;/a&gt;, surveying 1,500+ marketers globally, found that website, blog, and SEO efforts remain the &lt;strong&gt;top ROI-driving channel for B2B companies&lt;/strong&gt;, ahead of paid social and email. For software companies selling to technical audiences, this matters more than average because developers actively search for solutions, read documentation, and compare tools before committing.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://contentmarketinginstitute.com/articles/b2b-content-marketing-trends-research-2" rel="noopener noreferrer"&gt;Content Marketing Institute's 2026 B2B report&lt;/a&gt; reinforces this across 1,000+ B2B marketers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Teams that invest in content strategy first, then layer AI on top, outperform teams that rely on AI alone&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;58% of B2B marketers&lt;/strong&gt; rate their content strategy as only "moderately effective," revealing a massive opportunity for companies willing to do the work properly&lt;/li&gt;
&lt;li&gt;Only &lt;strong&gt;one-third&lt;/strong&gt; have scalable content creation models, meaning most companies are bottlenecked by production capacity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For technology companies specifically, the &lt;a href="https://contentmarketinginstitute.com/technology-research/content-marketing-technology-research" rel="noopener noreferrer"&gt;CMI Technology Content Marketing report&lt;/a&gt; found that tech marketers are more confident, better aligned with sales, and more mature in AI adoption than other B2B industries. The gap is narrowing, which means the advantage goes to teams that execute faster and with higher quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Actually Converts
&lt;/h2&gt;

&lt;p&gt;Not all content is created equal. Research on enterprise software companies shows a clear hierarchy of what drives leads and conversions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;High ROI:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Original research and benchmarks your company owns&lt;/li&gt;
&lt;li&gt;Long-form technical guides that solve specific problems&lt;/li&gt;
&lt;li&gt;Customer case studies with measurable outcomes&lt;/li&gt;
&lt;li&gt;Interactive tools (ROI calculators, diagnostic assessments)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Moderate ROI:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tutorial blog posts with working code examples&lt;/li&gt;
&lt;li&gt;Comparison and migration guides&lt;/li&gt;
&lt;li&gt;Video walkthroughs and product demos&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Low ROI (relative to effort):&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generic promotional blog posts&lt;/li&gt;
&lt;li&gt;Company news announcements&lt;/li&gt;
&lt;li&gt;Organic social media without a distribution strategy&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The pattern: content that helps developers &lt;em&gt;do something&lt;/em&gt; outperforms content that tells developers &lt;em&gt;about something&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Developer Content is Different
&lt;/h2&gt;

&lt;p&gt;Developers are not a typical marketing audience. The 2025 Stack Overflow Developer Survey, with 49,000+ responses, shows that trust in AI-generated content is falling (down from 40% to 29% year-over-year), and &lt;strong&gt;75% of developers prefer asking a person&lt;/strong&gt; over relying on automated answers.&lt;/p&gt;

&lt;p&gt;This creates a specific dynamic for software content:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Accuracy matters more than polish.&lt;/strong&gt; A technically correct blog post with basic formatting will outperform a beautifully designed piece with code errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Peer trust drives decisions.&lt;/strong&gt; Developers trust other developers. Content written by engineers, reviewed by engineers, and published in developer communities carries more weight than corporate marketing copy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search is the primary discovery channel.&lt;/strong&gt; Developers Google problems. If your content answers their question well, you earn attention at the exact moment they need a solution.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Compounding Effect
&lt;/h2&gt;

&lt;p&gt;Content marketing's real advantage over paid acquisition is compounding. A paid ad stops working the moment you stop spending. A well-written technical guide continues generating traffic, backlinks, and sign-ups for years.&lt;/p&gt;

&lt;p&gt;Here's what that looks like in practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Month 1-3:&lt;/strong&gt; New content gets indexed, starts ranking for long-tail keywords&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Month 3-6:&lt;/strong&gt; Top-performing pieces climb in search rankings, referral traffic builds&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Month 6-12:&lt;/strong&gt; Compounding begins, existing content drives more traffic than new content&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Year 2+:&lt;/strong&gt; Content library becomes a moat, organic traffic grows without proportional spend increases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The 2026 Draft.dev Developer Marketing Survey found that &lt;strong&gt;51% of developer marketing teams are increasing content and SEO investment&lt;/strong&gt; this year. The teams that started two years ago are now reaping the compound returns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Traps
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Trap 1: Publishing without distribution.&lt;/strong&gt; Writing a blog post and hoping people find it isn't a strategy. Every piece needs a distribution plan: email, social, community syndication, and developer platform cross-posting.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trap 2: Optimizing for volume over quality.&lt;/strong&gt; Publishing four mediocre posts per month is worse than publishing one excellent post. Developers can tell the difference instantly, and so can search engines.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trap 3: Ignoring technical accuracy.&lt;/strong&gt; If your code examples don't work, developers will leave and won't come back. Every technical post should be reviewed by an engineer who has actually run the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Trap 4: No measurement framework.&lt;/strong&gt; Track organic traffic, time on page, sign-up attribution, and keyword rankings. Content without measurement is a cost center. Content with measurement is a growth engine. Our guide to &lt;a href="https://dev.to/blog/developer-tool-content-roi-beyond-pageviews"&gt;measuring developer content ROI beyond pageviews&lt;/a&gt; shows what to track.&lt;/p&gt;

&lt;h2&gt;
  
  
  What We Recommend
&lt;/h2&gt;

&lt;p&gt;For developer tool companies considering a content investment in 2026:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start with search intent.&lt;/strong&gt; Identify the questions your target developers are already Googling. Build content that answers those questions better than anything currently ranking.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Invest in technical depth.&lt;/strong&gt; Shallow overviews don't rank and don't convert. Write the guide you wish existed when you were building your product.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Build a distribution system.&lt;/strong&gt; Cross-post to Dev.to, Medium, and Hashnode. Share in relevant Discord servers and subreddits. Syndicate through newsletter sponsorships. Make every piece work across multiple channels, as in our &lt;a href="https://dev.to/blog/how-to-distribute-technical-content-reddit-x-youtube"&gt;channel-by-channel distribution playbook&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure and iterate.&lt;/strong&gt; Set up attribution. Know which posts drive sign-ups, which drive awareness, and which underperform. Double down on what works.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be consistent.&lt;/strong&gt; The compounding effect only works if you publish regularly. One post per week is better than a burst of ten posts followed by three months of silence.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The Bottom Line
&lt;/h2&gt;

&lt;p&gt;Content marketing for software companies isn't optional in 2026. It's the most cost-effective way to reach developers, build trust, and drive sustainable growth. The question isn't whether to invest, but whether you're investing enough and executing well enough to compete.&lt;/p&gt;

</description>
      <category>contentwriting</category>
      <category>strategy</category>
      <category>growth</category>
    </item>
    <item>
      <title>Gemini 4 Neon Review: Pricing, Benchmarks, and Coding Tests</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Fri, 20 Nov 2026 09:44:21 +0000</pubDate>
      <link>https://dev.to/studio1hq/-gemini-4-neon-review-pricing-benchmarks-and-coding-tests-pfe</link>
      <guid>https://dev.to/studio1hq/-gemini-4-neon-review-pricing-benchmarks-and-coding-tests-pfe</guid>
      <description>&lt;blockquote&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;If you want the quick take, Neon is the Gemini 4 model most developers will actually end up using. It's close to Carbon at about half the price, and the catch is how much it likes to talk.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It matches Carbon for roughly half the money. At the default "high" setting, Artificial Analysis scores both at 60. Neon costs $3.74 per task, and Carbon costs $7.76.&lt;/li&gt;
&lt;li&gt;The $3 in and $15 out price is only half the story. Neon writes a lot of tokens, so run it on high. The xhigh setting adds 1.8 points for $2.70 more per task.&lt;/li&gt;
&lt;li&gt;In a six-app coding test, it came second out of 18 models, behind only Claude Fable 5.2, and cost a fraction of what Fable did.&lt;/li&gt;
&lt;li&gt;It trusts old training data and tests like a developer, not an attacker. Review anything touching security or a recently changed API.&lt;/li&gt;
&lt;li&gt;It's Google's fourth Gemini 4 model in about seven weeks, so test it on your own tasks before you commit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Google released Gemini 4 Neon on November 18, 2026. It's a mid-tier model that costs $3 per million input tokens and $15 per million output tokens, has a 1M-token context window, and scores 61 on the Artificial Analysis Intelligence Index at top effort. At default effort, it roughly matches Gemini 4 Carbon for half the cost per task.&lt;/p&gt;

&lt;p&gt;It's also the fourth Gemini 4 model in about seven weeks, so yes, people had jokes. One Hacker News commenter is already &lt;a href="https://news.ycombinator.com/item?id=50552763" rel="noopener noreferrer"&gt;waiting for Oganesson&lt;/a&gt;. Google is speedrunning the periodic table.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Gemini 4 Neon?
&lt;/h2&gt;

&lt;p&gt;Google's Gemini 4 family now has three tiers that matter. Hydrogen is the fast, cheap one. Carbon is the slow, deep one. Neon sits in the middle, and the &lt;a href="https://deepmind.google/models/model-cards/gemini-4-neon/" rel="noopener noreferrer"&gt;model card&lt;/a&gt; says it's adapted from Carbon.&lt;/p&gt;

&lt;p&gt;Neon is built for long coding jobs, analysis, and agents that need to finish fast. It has a 1M-token context window and four thinking levels: low, medium, high (the API default), and xhigh. It takes in text, images, audio, video, and PDFs, and it writes text only. Output is 64K tokens per response by default, and up to 1M through a background long-decode mode. The knowledge cutoff is March 2026.&lt;/p&gt;

&lt;p&gt;You can get it on the paid Gemini API tier, in Google AI Studio and Android Studio, in Antigravity, in Gemini for business, and in the Gemini app for Pro and Ultra subscribers. Day-one integrations included &lt;a href="https://latent.space/p/ainews-gemini-4-neon-gdm-s-opus-sol-contender/" rel="noopener noreferrer"&gt;Cursor, GitHub Copilot, and LangChain&lt;/a&gt;. Argon quietly left the Gemini app the same day.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbhupflkpv9lgcoysj9e4.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fbhupflkpv9lgcoysj9e4.png" alt="*Release gaps keep shrinking. Source: Arena counts via Latent Space.*" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How it differs from the other models
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Gemini 4 Neon&lt;/th&gt;
&lt;th&gt;Gemini 4 Carbon&lt;/th&gt;
&lt;th&gt;Gemini 4 Hydrogen&lt;/th&gt;
&lt;th&gt;Claude Opus 5.5&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;API name&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;gemini-4-neon&lt;/td&gt;
&lt;td&gt;gemini-4-carbon&lt;/td&gt;
&lt;td&gt;gemini-4-hydrogen&lt;/td&gt;
&lt;td&gt;claude-opus-5-5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Input / output price&lt;/strong&gt; (per 1M tokens)&lt;/td&gt;
&lt;td&gt;$3 / $15&lt;/td&gt;
&lt;td&gt;$2 / $10 now, $4 / $20 from Dec 1&lt;/td&gt;
&lt;td&gt;$1.50 / $7.50&lt;/td&gt;
&lt;td&gt;$4 / $20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;strong&gt;Cache reads&lt;/strong&gt; (per 1M tokens)&lt;/td&gt;
&lt;td&gt;$0.15&lt;/td&gt;
&lt;td&gt;$0.10 now, $0.20 from Dec 1&lt;/td&gt;
&lt;td&gt;$0.075&lt;/td&gt;
&lt;td&gt;$0.20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;AA Intelligence Index&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;61 at xhigh, 59.6 at high&lt;/td&gt;
&lt;td&gt;60 at high&lt;/td&gt;
&lt;td&gt;54 at xhigh&lt;/td&gt;
&lt;td&gt;59 at max&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Output speed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;About 110 tokens/sec&lt;/td&gt;
&lt;td&gt;About 57 tokens/sec&lt;/td&gt;
&lt;td&gt;About 170 tokens/sec&lt;/td&gt;
&lt;td&gt;Not listed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Context / max output&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1M / 64K (1M via background decode)&lt;/td&gt;
&lt;td&gt;1M&lt;/td&gt;
&lt;td&gt;1M&lt;/td&gt;
&lt;td&gt;1M / 128K&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best for&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Complex work you run often&lt;/td&gt;
&lt;td&gt;Hardest long projects&lt;/td&gt;
&lt;td&gt;Everyday speed&lt;/td&gt;
&lt;td&gt;Long coding jobs, big refactors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Sources: &lt;a href="https://venturebeat.com/technology/google-launches-gemini-4-neon-with-opus-5-5-level-coding-performance-at-25-lower-api-token-prices" rel="noopener noreferrer"&gt;VentureBeat&lt;/a&gt; for prices and speeds, &lt;a href="https://artificialanalysis.ai/articles/gemini-4-neon-intelligence-gain" rel="noopener noreferrer"&gt;Artificial Analysis&lt;/a&gt;, &lt;a href="https://www.studio1hq.com/blog/claude-opus-5-5-review-motion-videos" rel="noopener noreferrer"&gt;Studio1's Opus 5.5 review&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compared with Carbon,&lt;/strong&gt; Neon matches the index score at high effort for roughly half the cost per task and about 60% less time. Carbon is still Google's pick for the hardest long-horizon projects, and it still leads Arena's Text Arena. It's also cheaper per token until November 30.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Against Opus 5.5,&lt;/strong&gt; Neon at high (59.6) is level with Opus at max (59.1) at about a third of the per-task cost. That compares different effort settings, so treat it as direction, not a verdict. In Google's own table, Opus is ahead by about a point on Terminal-Bench 4.1 and FrontierCode 2.0.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compared to GPT-6.2 Sol and Astra,&lt;/strong&gt; Neon wins on long context and the Vals Index, and loses on cost per task. Sol scores 57.3 for $1.01 a task. Astra scores 60.1 for $2.07.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compared to Hydrogen,&lt;/strong&gt; Neon is about 8.8 index points smarter at high and costs about twice as much per task, per &lt;a href="https://www.eesel.ai/blog/gemini-4-neon-review" rel="noopener noreferrer"&gt;eesel's read of the data&lt;/a&gt;. Antigravity now lets you &lt;a href="https://antigravity.google/blog/gemini-4-neon-in-google-antigravity/" rel="noopener noreferrer"&gt;pair them&lt;/a&gt;: Neon plans, Hydrogen does the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  What breaks when you switch
&lt;/h2&gt;

&lt;p&gt;Google's &lt;a href="https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/guides/gemini-4-neon" rel="noopener noreferrer"&gt;developer guide&lt;/a&gt; calls Neon the upgrade target for Gemini 3.1 Pro, and for complex coding work moving off Argon or Gemini 3.8 Flash. Nothing here ruins your day, but you can't flip the switch and forget about it. These are the four you'll actually hit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One shared token budget.&lt;/strong&gt; Input, thinking, tool calls, and the final answer all draw from the same 1,048,576 tokens. Gemini 3 had separate limits. A long reasoning run now eats your window.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The default effort changes by surface.&lt;/strong&gt; The API defaults to high. The Gemini app defaults to low, and only offers low, medium, and high. The 61 headline score was measured at xhigh, which app users can't pick.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sampling is locked on Google Cloud.&lt;/strong&gt; The enterprise platform lists temperature at 1.0, topP at 0.95, and topK at 64, with custom values ignored. Tuning and the RAG Engine aren't supported there, and access is limited to verified enterprise customers in select regions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Capacity and access are rough.&lt;/strong&gt; In 13 early Antigravity sessions, one tester logged &lt;a href="https://latent.space/p/ainews-gemini-4-neon-gdm-s-opus-sol-contender/" rel="noopener noreferrer"&gt;57 capacity errors and four stalled runs&lt;/a&gt;. There's also no free API tier, and Auto mode in the Gemini app doesn't route to Neon.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One more thing. Google says the full safety report is still on the way, so if you work in a regulated space, wait for it before you go to production.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it will really cost you
&lt;/h2&gt;

&lt;p&gt;Google says Neon cuts cost per task by 32% against Carbon at the default high setting. Artificial Analysis frames it more modestly, at about 17% lower when it compares Neon at xhigh with Carbon at high, using Carbon's standard price. The gap between those numbers is mostly about which settings you compare.&lt;/p&gt;

&lt;p&gt;First, the sticker price. Here's where Neon sits among the models people compare it with:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fznhslztby8s0urjrwjn9.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fznhslztby8s0urjrwjn9.png" alt="*List price per million tokens. Source: VentureBeat price table.*" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Then the number that hits your invoice, which is cost per task:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fedfw5p8xsgfrylealil5.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fedfw5p8xsgfrylealil5.png" alt="*Cost per task at each effort level. Data: Artificial Analysis, compiled by eesel.ai.*" width="800" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's how that plays out by setting, from &lt;a href="https://www.eesel.ai/blog/gemini-4-neon-review" rel="noopener noreferrer"&gt;eesel's compilation of Artificial Analysis data&lt;/a&gt;:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Neon setting&lt;/th&gt;
&lt;th&gt;Index score&lt;/th&gt;
&lt;th&gt;Cost per task&lt;/th&gt;
&lt;th&gt;Minutes per task&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;44.1&lt;/td&gt;
&lt;td&gt;$0.75&lt;/td&gt;
&lt;td&gt;3.7&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;54.9&lt;/td&gt;
&lt;td&gt;$1.90&lt;/td&gt;
&lt;td&gt;8.3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;High (default)&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;59.6&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;$3.74&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;14.8&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Extra high&lt;/td&gt;
&lt;td&gt;61.4&lt;/td&gt;
&lt;td&gt;$6.44&lt;/td&gt;
&lt;td&gt;21.5&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;High is the sweet spot. Medium to high buys 4.7 points for $1.84 more. High to xhigh buys 1.8 points for $2.70 more and nearly seven extra minutes. xhigh is the "one more episode" of reasoning settings.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi9jda2mzysds08932ib0.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fi9jda2mzysds08932ib0.png" alt="*The curve flattens after high. Source: Artificial Analysis, compiled by eesel.ai.*" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It also gets wordy there. At xhigh, Neon wrote 283 million output tokens across the index, against 60.9 million for Sol, and the first answer token takes about 56 seconds. Fine for a background agent. Bad for a chat box.&lt;/p&gt;

&lt;p&gt;Coding is a different story. In MindStudio's &lt;a href="https://www.mindstudio.ai/blog/gemini-4-neon-vs-claude-opus-gpt-6-2" rel="noopener noreferrer"&gt;KingBench 4 test&lt;/a&gt;, a full six-app run cost $20.36 on Neon at list prices, against $222 for Fable 5.2 and $234 for Carbon on its intro pricing. Neon used about 27 million tokens, and Carbon used roughly three times as many. So on code, Neon is lean. On general reasoning tasks, it's chatty. Both are true, which is the whole point of measuring cost per finished task and not price per token.&lt;/p&gt;

&lt;p&gt;A few more prices, if you're budgeting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cached input:&lt;/strong&gt; $0.15 per million, a 95% discount.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Batch and Flex:&lt;/strong&gt; half price, $1.50 in and $7.50 out, per &lt;a href="https://felloai.com/gemini-4-neon/" rel="noopener noreferrer"&gt;Fello AI&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The December 1 flip:&lt;/strong&gt; Carbon doubles to $4 and $20. Until then, Neon costs 50% more per token than Carbon. After, it's 25% cheaper. Fun.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI:&lt;/strong&gt; Sol is $2 and $10, and Astra is $8 and $40. Astra writes about 17,800 tokens per task, while Neon writes about 90,000, so it still comes out cheaper per task on Artificial Analysis.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The test scores
&lt;/h2&gt;

&lt;p&gt;Benchmarks are standard exams for models. These are the ones that matter for dev work, from Google's own comparison table (best score in bold):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Test&lt;/th&gt;
&lt;th&gt;What it checks&lt;/th&gt;
&lt;th&gt;Neon&lt;/th&gt;
&lt;th&gt;Opus 5.5&lt;/th&gt;
&lt;th&gt;Sol&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Vals Index&lt;/td&gt;
&lt;td&gt;Finance, legal, tax, and software tasks&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70.9%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;70.1%&lt;/td&gt;
&lt;td&gt;66.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminal-Bench 4.1&lt;/td&gt;
&lt;td&gt;Multi-step tasks in a command line&lt;/td&gt;
&lt;td&gt;65.2%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;65.8%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;61.5%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;FrontierCode 2.0&lt;/td&gt;
&lt;td&gt;Would a reviewer merge the change&lt;/td&gt;
&lt;td&gt;46.2%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;47.3%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;43.8%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AutomationBench&lt;/td&gt;
&lt;td&gt;Business tasks across many apps&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;56.3%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;42.5%&lt;/td&gt;
&lt;td&gt;41.3%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;HLE-Diamond&lt;/td&gt;
&lt;td&gt;Very hard expert questions&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;71.3%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;67.9%&lt;/td&gt;
&lt;td&gt;64.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Terminal-Bench Science&lt;/td&gt;
&lt;td&gt;Science research tasks&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;70.5%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;63.3%&lt;/td&gt;
&lt;td&gt;68.0%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chartography&lt;/td&gt;
&lt;td&gt;Reading dense professional charts&lt;/td&gt;
&lt;td&gt;73.5%&lt;/td&gt;
&lt;td&gt;66.3%&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;75.1%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GraphWalks, 256K to 1M&lt;/td&gt;
&lt;td&gt;Recall across a huge context&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;95.2%&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;66.8%&lt;/td&gt;
&lt;td&gt;80.1%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx618j6c2rdoksaewd935.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fx618j6c2rdoksaewd935.png" alt="*Google's published comparison. Vendor-reported. Sources: Google DeepMind model card via Fello AI and VentureBeat.*" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are best-case scores from Google's own runs, and the table leaves out Fable 5.2 and Astra, which both beat Neon on the Artificial Analysis index. So here are the independent numbers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Artificial Analysis Intelligence Index:&lt;/strong&gt; 61 at xhigh, third overall behind Astra and Fable 5.2, and one point ahead of Carbon.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Artificial Analysis Coding Agent Index:&lt;/strong&gt; 59 using the Antigravity CLI, against 55 for Carbon. That's &lt;a href="https://x.com/ArtificialAnlys/status/2123170648772288540" rel="noopener noreferrer"&gt;in line with Claude Code running Fable 5.2 and Opus 5.5 at 58&lt;/a&gt;, at $6.86 per task versus $12.61 for Opus and $15.47 for Fable.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Vals Index:&lt;/strong&gt; second place at 70.9%, &lt;a href="https://latent.space/p/ainews-gemini-4-neon-gdm-s-opus-sol-contender/" rel="noopener noreferrer"&gt;about 0.4 points behind Fable 5.2&lt;/a&gt; at less than half the cost per task. Sonnet 5.5 sits at 70.85%, which is basically a tie.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent Arena:&lt;/strong&gt; second place with 1,336 points over about 4,200 real sessions and a $2.82 median task cost.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;KingBench 4:&lt;/strong&gt; 37.9 out of 60, second of 18 models. Fable 5.2 scored 42, Opus 5.5 scored 34.7, and GPT-6.2 Astra scored about 33.9. Neon got 70 to 95% of each project right on the first try, with three full file rewrites across six builds against 31 for Fable. The harnesses differed between models, so read it as a signal, not a verdict.&lt;/li&gt;
&lt;/ul&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxn096yjbbwh9rp1nwcj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flxn096yjbbwh9rp1nwcj.png" alt="*KingBench 4 score and cost. Source: MindStudio. Models ran in different harnesses, so read it as a signal, not a verdict.*" width="799" height="333"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One number from Google's own post deserves a second look. On SWE-sweep, Neon scores 12.8% in the shared mini-SWE harness and 39.0% inside Antigravity. Same model, three times the score. The tooling around the model matters as much as the model.&lt;/p&gt;

&lt;h2&gt;
  
  
  What have people built with it?
&lt;/h2&gt;

&lt;p&gt;These are some of the things people have shown in the first two days. They're demos people chose to post, so treat them as best cases.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A 12-hour Turing study.&lt;/strong&gt; Google showed a swarm of Neon agents in Antigravity &lt;a href="https://x.com/GoogleAI/status/2123168242797809944" rel="noopener noreferrer"&gt;recreating Alan Turing's 1936 Cambridge study&lt;/a&gt; from archival photos, complete with a working universal Turing machine you can run.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A path-traced showcase.&lt;/strong&gt; Google for Developers shared &lt;a href="https://x.com/googledevs/status/2123176874818084938" rel="noopener noreferrer"&gt;a build with 1,000 Hz physics, 1,728 path-traced frames, and a custom synth score&lt;/a&gt;, all driven from one swarm.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;17 demos in a day.&lt;/strong&gt; Early-access tester &lt;a href="https://x.com/kimmonismus/status/2123168299890704735" rel="noopener noreferrer"&gt;Kimmonismus&lt;/a&gt; had Neon build shooters and 3D worlds in Antigravity. One build died on a server error and needed a second pass. In a bug-fix test, a booking checker went from 1 of 5 tests passing to 5 of 5.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A 3D room designer and a playable Pokémon Red.&lt;/strong&gt; In the KingBench tests, Neon built a room editor with 15 furniture types and no WebGL memory leaks, then a first-chapter Pokémon game with 18 connected maps running at 60 frames per second.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An ops agent on Cloud Run.&lt;/strong&gt; In &lt;a href="https://www.geeky-gadgets.com/gemini-4-neon-features/" rel="noopener noreferrer"&gt;one hands-on writeup&lt;/a&gt;, Neon built an agent called Pager that watches an app, finds a fault, and applies a fix after human approval. It was deployed to Cloud Run in about 65 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Copy duty.&lt;/strong&gt; Theo of T3 Code &lt;a href="https://x.com/theo/status/2123273253850628260" rel="noopener noreferrer"&gt;now uses Neon as his exclusive copywriter&lt;/a&gt;, with Fable on implementation and Astra on playtesting. In October, he'd called Argon &lt;a href="https://x.com/theo/status/2110461582237188207" rel="noopener noreferrer"&gt;unusable for real code work&lt;/a&gt;, so that's a turn.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where it still loses
&lt;/h2&gt;

&lt;p&gt;Not everything's better. A few real gaps before you switch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stale knowledge.&lt;/strong&gt; In the &lt;a href="https://www.mindstudio.ai/blog/gemini-4-neon-vs-claude-opus-gpt-6-2" rel="noopener noreferrer"&gt;KingBench run&lt;/a&gt;, Neon coded a Fitbit app against an API Google had shut down on November 2. It also sent a wrong hex code that put a keyboard into bootloader mode. It trusts what it remembers instead of checking live docs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security testing.&lt;/strong&gt; Its &lt;a href="https://www.mindstudio.ai/blog/gemini-4-neon-vs-claude-opus-gpt-6-2" rel="noopener noreferrer"&gt;Docker alternative&lt;/a&gt; was clean Go code, but a hostile container image could escape to the host through seven symlink paths. Opus 5.5 and the GPT-6.2 models avoided that flaw. Neon tests the happy path.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Overclaiming.&lt;/strong&gt; In the &lt;a href="https://www.mindstudio.ai/blog/gemini-4-neon-vs-claude-opus-gpt-6-2" rel="noopener noreferrer"&gt;Pokémon build&lt;/a&gt;, its own test suite quietly rigged the game to guarantee a win. Check its summaries before you trust them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The hardest builds.&lt;/strong&gt; Fable 5.2 still &lt;a href="https://www.mindstudio.ai/blog/gemini-4-neon-vs-claude-opus-gpt-6-2" rel="noopener noreferrer"&gt;beat it, 42 to 37.9&lt;/a&gt;. If your evals fail at high effort, that's your next step up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cost per task against OpenAI.&lt;/strong&gt; Sol and Astra are cheaper per finished task on Artificial Analysis, per &lt;a href="https://www.eesel.ai/blog/gemini-4-neon-review" rel="noopener noreferrer"&gt;eesel's compilation&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Coding by a hair, and charts.&lt;/strong&gt; Opus leads Neon on &lt;a href="https://deepmind.google/models/model-cards/gemini-4-neon/" rel="noopener noreferrer"&gt;two coding rows&lt;/a&gt; by about a point, and Sol leads on chart reading.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Day one.&lt;/strong&gt; &lt;a href="https://latent.space/p/ainews-gemini-4-neon-gdm-s-opus-sol-contender/" rel="noopener noreferrer"&gt;Capacity errors&lt;/a&gt; showed up, and almost every number in this post is a launch-day number. One reviewer reports Neon guessing wrong on only 14% of questions it can't answer, against 50% or more for rivals, but it also answers fewer questions correctly. That's &lt;a href="https://www.eesel.ai/blog/gemini-4-neon-review" rel="noopener noreferrer"&gt;one reading of one benchmark&lt;/a&gt;, so verify it on &lt;a href="https://artificialanalysis.ai/models/gemini-4-neon" rel="noopener noreferrer"&gt;Artificial Analysis&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And then there's the naming. Nobody could work out the ordering. Simon Willison wrote that Neon made the Gemini 4 pricing &lt;a href="https://simonwillison.net/2026/Nov/18/llm-gemini/" rel="noopener noreferrer"&gt;even more confusing&lt;/a&gt;, and the &lt;a href="https://news.ycombinator.com/item?id=50552424" rel="noopener noreferrer"&gt;Hacker News thread&lt;/a&gt; is mostly people trying to guess the logic. Google's Logan Kilpatrick admitted the team is having a little too much fun with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is Gemini 4 Neon?
&lt;/h3&gt;

&lt;p&gt;Gemini 4 Neon is Google's mid-tier frontier model, released November 18, 2026. It sits between Gemini 4 Hydrogen and Gemini 4 Carbon, has a 1M-token context window, and is built for coding, analysis, and long agent workflows.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much does Gemini 4 Neon cost?
&lt;/h3&gt;

&lt;p&gt;It costs $3 per million input tokens and $15 per million output tokens, with cached input at $0.15. Batch requests are half price. On Artificial Analysis tasks, it averages $3.74 at high effort and $6.44 at xhigh.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Gemini 4 Neon better than Claude Opus 5.5?
&lt;/h3&gt;

&lt;p&gt;On the Artificial Analysis index, it's roughly level at a lower price, and it wins most rows in Google's own table. Opus 5.5 is about a point ahead on Terminal-Bench 4.1 and FrontierCode 2.0, and it handled container security better in one coding test. Try both on your own tasks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Gemini 4 Neon free?
&lt;/h3&gt;

&lt;p&gt;No. The API has no free tier, and the Gemini app needs a Google AI Pro or Ultra plan. Hydrogen is the Gemini 4 model with free API access.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which thinking level should I use?
&lt;/h3&gt;

&lt;p&gt;High, which is also the API default. It scores 59.6 on the Artificial Analysis index at $3.74 per task. xhigh adds about 1.8 points for $2.70 more per task and a longer wait.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;Neon is the Gemini model we'd test first this month. It's faster than Carbon, cheaper than the model it came from, and it holds up against Opus 5.5 on most of the numbers we can check.&lt;/p&gt;

&lt;p&gt;It's not for everything. Security work, anything touching recently changed APIs, and the very hardest builds still need a second look, and the December 1 price flip means your math changes in under two weeks.&lt;/p&gt;

&lt;p&gt;Test it on your own tasks before you switch, and run it on high. If you're weighing it against the others, our &lt;a href="https://www.studio1hq.com/blog/claude-opus-5-5-review-motion-videos" rel="noopener noreferrer"&gt;Opus 5.5 review&lt;/a&gt; covers the other side of that comparison, and our &lt;a href="https://www.studio1hq.com/blog/how-to-get-your-tool-recommended-by-chatgpt-perplexity-google" rel="noopener noreferrer"&gt;guide to getting your tool recommended by AI search&lt;/a&gt; covers what to do if you're the one building the tool.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>neon</category>
      <category>gemini</category>
    </item>
    <item>
      <title>Build a Cheapest Flight Date Finder with Next.js and SearchApi</title>
      <dc:creator>Arindam Majumder </dc:creator>
      <pubDate>Fri, 13 Nov 2026 15:50:29 +0000</pubDate>
      <link>https://dev.to/studio1hq/build-a-cheapest-flight-date-finder-with-nextjs-and-searchapi-2710</link>
      <guid>https://dev.to/studio1hq/build-a-cheapest-flight-date-finder-with-nextjs-and-searchapi-2710</guid>
      <description>&lt;p&gt;Flight booking sites make it rigid when you want to take a trip: you’ve got to pick a date. Sometimes, you don’t know exactly when you want to fly, but you have a timeframe in mind. Finding the cheapest day to fly within your timeframe would require you to manually check every route combination, which can be time-consuming.&lt;/p&gt;

&lt;p&gt;This article teaches you how to build a cheapest-fly-date-finder using Next.js and SearchApi. The app takes a route, a departure window, and a trip duration to find round-trip date pairs ranked by price using the SearchApi’s Google Flights Calendar API.&lt;/p&gt;

&lt;p&gt;For example, say you want to fly from New York to London any day between the 1st and 7th of November and stay for 7 days; the app returns the cheapest round-trip pair within your departure window (6th - 13th Nov at $692 at the time of writing this article).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Try&lt;/strong&gt; out the tool &lt;a href="https://cheapest-fly-date-finder.vercel.app/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.The full code is on &lt;a href="https://github.com/Studio1HQ/cheapest-fly-date-finder" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Basic familiarity with JavaScript or TypeScript and Next.js.&lt;/li&gt;
&lt;li&gt;Node.js (v 20.9.0 or later) and npm are installed on your local machine.&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://www.searchapi.io/?utm_source=Dev&amp;amp;utm_medium=Ambassador&amp;amp;utm_campaign=studio1hq.com" rel="noopener noreferrer"&gt;SearchApi&lt;/a&gt; account and API key. If you don’t have one, create a free account and get 100 free searches.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Set up the project and add your SearchApi key
&lt;/h2&gt;

&lt;p&gt;Clone the repo and install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Studio1HQ/cheapest-fly-date-finder.git
&lt;span class="nb"&gt;cd&lt;/span&gt; cheapest-fly-date-finder/frontend
npm install
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create your &lt;code&gt;.env&lt;/code&gt; file and add your API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="na"&gt;SEARCHAPI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;your_key_here&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;npm run dev&lt;/code&gt; and open &lt;code&gt;http://localhost:3000&lt;/code&gt; to confirm the search form loads.&lt;/p&gt;

&lt;h2&gt;
  
  
  A quick look at the architecture
&lt;/h2&gt;

&lt;p&gt;The app is a Next.js app with a form and 2 API routes that call SearchApi: &lt;code&gt;api/location&lt;/code&gt; and &lt;code&gt;api/calendar&lt;/code&gt;. Form handling, autocomplete interactions, and showing of results are handled client-side while the routes communicate with SearchApi on the backend.&lt;/p&gt;

&lt;p&gt;As a user types the name of their location(s), requests are made to the &lt;a href="https://www.searchapi.io/docs/google-flights-location-search-api/?utm_source=Dev&amp;amp;utm_medium=Ambassador&amp;amp;utm_campaign=studio1hq.com" rel="noopener noreferrer"&gt;Flights Location Search API&lt;/a&gt; to fetch cities and airport suggestions. When the user submits the form, the departure window, locations (route), and trip duration are sent to the SearchApi Flights Calendar API through the &lt;code&gt;api/calendar&lt;/code&gt; route. The route filters and ranks the returned fare combinations before sending it to the client.&lt;/p&gt;

&lt;p&gt;This design replaces one search per date pair with a single calendar request.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff3fldjy9tmy2whjvk55f.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ff3fldjy9tmy2whjvk55f.png" alt="Architecture of the cheapest-day-to-fly finder: browser components call two Next.js API routes, which call SearchApi’s location and Flights Calendar endpoints" width="800" height="625"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the codebase, &lt;code&gt;LocationAutocomplete.tsx&lt;/code&gt; and &lt;code&gt;SearchForm.tsx&lt;/code&gt; handle the search inputs. &lt;code&gt;CheapestDayFinder.tsx&lt;/code&gt; connects form submission to the calendar search, while the &lt;code&gt;location route&lt;/code&gt; and &lt;code&gt;calendar route&lt;/code&gt; make the server-side provider calls. &lt;code&gt;ResultsPanel.tsx&lt;/code&gt; and &lt;code&gt;FareRow.tsx&lt;/code&gt; present the search outcome.&lt;/p&gt;

&lt;p&gt;The rest of the article follows that flow: Stage One collects the travel details, Stage Two turns them into a Calendar API request, and Stage Three transforms the returned calendar data into ranked results.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Live tool
&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj8tyojgk01kbtf08vrcz.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fj8tyojgk01kbtf08vrcz.png" alt="Image2" width="800" height="543"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 1: Build the search form with city and airport autocomplete
&lt;/h2&gt;

&lt;p&gt;Stage One builds a search form that collects four inputs: origin, destination, departure window, and trip duration. The Flights API identifies airports and cities by IATA codes (unique three-letter codes, such as &lt;code&gt;JFK&lt;/code&gt;), which most travelers don’t know, so the form uses SearchApi’s Google &lt;a href="https://www.searchapi.io/docs/google-flights-location-search-api/?utm_source=Dev&amp;amp;utm_medium=Ambassador&amp;amp;utm_campaign=studio1hq.com" rel="noopener noreferrer"&gt;Flights Location Search API&lt;/a&gt; to power an autocomplete that accepts city or airport names.&lt;/p&gt;

&lt;h3&gt;
  
  
  Making location search responsive
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;LocationAutocomplete&lt;/code&gt; component fetches location suggestions after the user types at least 2 characters. It waits 300ms before making the request to avoid unnecessary API calls as the user types.&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="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;isManualSelectionRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;isManualSelectionRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;AbortController&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;timer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&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="nf"&gt;setIsLoading&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="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="n"&gt;res&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/location"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;departure&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="n"&gt;signal&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;signal&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&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="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Location fetch failed"&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="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LocationItem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;locations&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="p"&gt;;&lt;/span&gt;

    &lt;span class="nf"&gt;setLocations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setIsOpen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&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="n"&gt;err&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;unknown&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"AbortError"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Failed to fetch location suggestions:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&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;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;setIsLoading&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;300&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;)&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;clearTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;timer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;controller&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;abort&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="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;AbortController&lt;/code&gt; cancels the previous request when the effect is cleaned up. &lt;/p&gt;

&lt;p&gt;Once suggestions arrive, the dropdown presents city results and airports listed under each city, if they’re available.&lt;/p&gt;

&lt;p&gt;Users can select either level. A city selection stores its short or full name; an airport selection stores a city label with its airport code when one is available.&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="n"&gt;selectCity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LocationItem&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="n"&gt;isManualSelectionRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;short_name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;full_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setLocations&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="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setIsOpen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;selectAirport&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;airport&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;AirportItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;city&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;LocationItem&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="n"&gt;isManualSelectionRef&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;airport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;airport_code&lt;/span&gt;
    &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="sb"&gt;`${city.short_name || airport.title} (${airport.airport_code})`&lt;/span&gt;
    &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;airport&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;onChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setLocations&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="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;setIsOpen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&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;The selection handlers allow users to choose a broad city result or a specific airport from the same field. The form passes&amp;nbsp;&lt;code&gt;departure={true}&lt;/code&gt;&amp;nbsp;for the origin and&amp;nbsp;&lt;code&gt;departure={false}&lt;/code&gt;&amp;nbsp;for the destination, which determines the search type used by the location route.&lt;/p&gt;

&lt;p&gt;The manual-selection flag prevents the selected value from sending another autocomplete API request. &lt;/p&gt;

&lt;h3&gt;
  
  
  Creating the location API route
&lt;/h3&gt;

&lt;p&gt;The autocomplete component sends the autocomplete queries to the &lt;code&gt;api/location&lt;/code&gt; route.&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;departure&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;query&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"No query provided"&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://www.searchapi.org/api/v1/search"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google_flights_location_search"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;q&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SEARCHAPI_API_KEY&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;search_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;departure&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s2"&gt;"departure"&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"arrival"&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;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${url}?${params}`&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="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;data&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"No location data found"&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;404&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;return&lt;/span&gt; &lt;span class="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&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="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"Error is: "&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;error&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Failed to fetch location data"&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&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="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;The route accepts the query and the&amp;nbsp;&lt;code&gt;departure&lt;/code&gt;&amp;nbsp;flag, then passes them to SearchApi as&amp;nbsp;&lt;code&gt;q&lt;/code&gt;&amp;nbsp;and&amp;nbsp;&lt;code&gt;search_type&lt;/code&gt;. It parses the provider response and returns that data to the autocomplete component, which reads its&amp;nbsp;&lt;code&gt;locations&lt;/code&gt;&amp;nbsp;field. &lt;/p&gt;

&lt;h3&gt;
  
  
  Setting the departure window and duration
&lt;/h3&gt;

&lt;p&gt;The form also needs to collect the time between when the user wants to depart and how long they intend to stay. You use date fields and number inputs to collect the data. This data determines the date combinations the app should compare.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;SearchForm&lt;/code&gt; component validates the form inputs and passes them in &lt;code&gt;FareSearchQuery&lt;/code&gt; to the &lt;code&gt;onSearch&lt;/code&gt; callback:&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="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="nc"&gt;SearchForm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;onSearch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;isSearching&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SearchFormProps&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="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FareSearchQuery&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;DEFAULT_QUERY&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="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setErrors&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FormErrors&lt;/span&gt;&lt;span class="o"&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;validate&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="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FormErrors&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FormErrors&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="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Enter an origin city or airport."&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="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Enter a destination city or airport."&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="k"&gt;from&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nf"&gt;normalizeLocation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nf"&gt;normalizeLocation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;to&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="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Destination must differ from the origin."&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Pick earliest departure date."&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="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Pick latest departure date."&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="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&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="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Latest date must be on or after earliest date."&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;dayDiff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;31&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Departure window cannot exceed 30 days."&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"Trip duration must be 1–60 days."&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="n"&gt;next&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="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The function checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the locations and dates are present&lt;/li&gt;
&lt;li&gt;That the locations differ&lt;/li&gt;
&lt;li&gt;That the departure dates are in order, and&lt;/li&gt;
&lt;li&gt;That the duration is an integer from 1 to 60&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the form’s JSX, the autocomplete fields and date/duration inputs update the same &lt;code&gt;query&lt;/code&gt; state:&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;// Inside SearchForm's return statement...&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LocationAutocomplete&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"search-from"&lt;/span&gt;
  &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Origin"&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"from"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"JFK or New York"&lt;/span&gt;
  &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;departure&lt;/span&gt;&lt;span class="o"&gt;=&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="o"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;LocationAutocomplete&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"search-to"&lt;/span&gt;
  &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Destination"&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"to"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"LHR or London"&lt;/span&gt;
  &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;departure&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Field&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"search-depart-after"&lt;/span&gt;
  &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Earliest departure"&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"departAfter"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Field&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"search-depart-before"&lt;/span&gt;
  &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Latest departure"&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"date"&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;onChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"departBefore"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;

&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Field&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"search-duration"&lt;/span&gt;
  &lt;span class="n"&gt;label&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"Length of stay (days)"&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"number"&lt;/span&gt;
  &lt;span class="n"&gt;min&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;max&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;onChange&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="n"&gt;val&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;val&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;val&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"durationDays"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&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="n"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"7"&lt;/span&gt;
  &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;departure&lt;/code&gt; flag in the &lt;code&gt;LocationAutocomplete&lt;/code&gt; component tells the autocomplete whether the search is for departure or arrival. The date fields capture the time window the user has to fly, and the duration is how long they’ll stay before returning.&lt;/p&gt;

&lt;p&gt;On successful validation, the submit handler sends the trimmed locations, date value, and duration to the &lt;code&gt;onSearch&lt;/code&gt; callback.&lt;/p&gt;

&lt;h3&gt;
  
  
  Connecting the inputs to the next stage
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;CheapestDayFinder&lt;/code&gt; component receives the query through the &lt;code&gt;onSearch&lt;/code&gt; callback of &lt;code&gt;SearchForm&lt;/code&gt;. It stores the query, extracts the airport codes where it can, and sends the search details to the &lt;code&gt;api/calendar&lt;/code&gt; route.&lt;/p&gt;

&lt;p&gt;Inside &lt;code&gt;CheapestDayFinder&lt;/code&gt;, &lt;code&gt;runSearch&lt;/code&gt; converts the form query into the calendar route’s request body:&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="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="nc"&gt;CheapestDayFinder&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setStatus&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;SearchStatus&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"idle"&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="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setResults&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FlightFare&lt;/span&gt;&lt;span class="p"&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="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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;activeQuery&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;setActiveQuery&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;useState&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FareSearchQuery&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;runSearch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useCallback&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FareSearchQuery&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="n"&gt;requestId&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setActiveQuery&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"loading"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nf"&gt;setResults&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="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// ...&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;originCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;extractAirportCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&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="n"&gt;destinationCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;extractAirportCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;to&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="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/api/calendar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="n"&gt;method&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"POST"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;headers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="s2"&gt;"Content-Type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"application/json"&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="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;originCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;destinationCode&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;durationDays&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;durationDays&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="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&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="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For a selected airport such as&amp;nbsp;&lt;code&gt;New York (JFK)&lt;/code&gt;,&amp;nbsp;&lt;code&gt;extractAirportCode&lt;/code&gt;&amp;nbsp;sends&amp;nbsp;&lt;code&gt;JFK&lt;/code&gt;. The request carries the route, departure window, and stay length to the &lt;code&gt;api/calendar&lt;/code&gt; route.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;requestId&lt;/code&gt; ref in &lt;code&gt;runSearch&lt;/code&gt; (&lt;code&gt;const id = ++requestId.current&lt;/code&gt;) prevents an older response from overwriting state after a newer request has begun.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;extractAirportCode&lt;/code&gt; extracts the three-letter unique identifier of an airport or city:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;extractAirportCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// 1. Matches "(LHR)" in "London (LHR)"&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;match&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Za&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;3&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="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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;match&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="n"&gt;match&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&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="c1"&gt;// 2. If the user typed a 3-letter code directly (e.g. "LHR" or "lhr")&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;trimmed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;location&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;/^&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="no"&gt;A&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="nc"&gt;Za&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;z&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;$&lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;trimmed&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;return&lt;/span&gt; &lt;span class="n"&gt;trimmed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toUpperCase&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="c1"&gt;// 3. Fallback to the original value if no code found (e.g. city name)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;trimmed&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 this point, the form has turned a traveler’s flexible plans into structured search input. In Stage Two, the app uses these values to construct and send a request to SearchApi’s Google Flights Calendar API.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 2: Query the Google Flights Calendar API from a Next.js route
&lt;/h2&gt;

&lt;p&gt;The app sends one request to SearchApi’s &lt;a href="https://www.searchapi.io/docs/google-flights-calendar-api/?utm_source=Dev&amp;amp;utm_medium=Ambassador&amp;amp;utm_campaign=studio1hq.com" rel="noopener noreferrer"&gt;Google Flights Calendar API&lt;/a&gt; for the whole departure window, and the &lt;code&gt;api/calendar&lt;/code&gt; route turns the returned fare combinations into a ranked list.&lt;/p&gt;

&lt;h3&gt;
  
  
  Preparing the calendar search
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;api/calendar&lt;/code&gt; route checks the request body for non-empty dates and locations before calling the Flights Calendar API. The check also ensures the user’s departure timeframe is not longer than 30 because of date combination limits.&lt;/p&gt;

&lt;p&gt;The checks happen in the top part of the route before you build the provider request:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;POST&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Request&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;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;durationDays&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;body&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="n"&gt;origin&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;destination&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;departBefore&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Origin, destination, and departure dates are required."&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;durationDays&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="o"&gt;!&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isInteger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;duration&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;duration&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;60&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Trip duration must be an integer between 1 and 60 days."&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&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="c1"&gt;// ...&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;SEARCHAPI_API_KEY&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="n"&gt;apiKey&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"SEARCHAPI_API_KEY is not configured on the server."&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&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="c1"&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="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&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;The route returns a client error for invalid inputs and a server error if the API key isn’t configured. &lt;/p&gt;

&lt;h3&gt;
  
  
  Constructing the outbound and return date ranges
&lt;/h3&gt;

&lt;p&gt;The route uses the trip duration input to shift both ends of the departure window, creating the corresponding return-date window.&lt;/p&gt;

&lt;p&gt;The date calculations and query parameters in the calendar route show how the app expresses that search to SearchApi:&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;// Inside the POST handler, after validating the request...&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;outboundStart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;outboundEnd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;returnStart&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;departAfter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration&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="n"&gt;returnEnd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;addDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;departBefore&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;duration&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="n"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://www.searchapi.org/api/v1/search"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URLSearchParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;engine&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"google_flights_calendar"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;flight_type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"round_trip"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;departure_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;arrival_id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;outbound_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;outboundStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;return_date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returnStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;outbound_date_start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;outboundStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;outbound_date_end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;outboundEnd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;return_date_start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returnStart&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;return_date_end&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;returnEnd&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;currency&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"USD"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;hl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"en"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;gl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"us"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;apiKey&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="c1"&gt;// ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The request selects SearchApi’s &lt;code&gt;google_flights_calendar&lt;/code&gt; as the engine to retrieve the flights data and specifies the &lt;code&gt;flight_type&lt;/code&gt; as a round trip. The request sets &lt;code&gt;flight_type&lt;/code&gt; to &lt;code&gt;round_trip&lt;/code&gt; so each calendar entry includes a return date. Round trip is the default, so this makes the intent explicit.&lt;/p&gt;

&lt;p&gt;The request includes both the start/end bounds for each date range and the &lt;code&gt;outbound_date&lt;/code&gt; and &lt;code&gt;return_date&lt;/code&gt; parameters, which are set to the start dates. The request also sets &lt;code&gt;currency&lt;/code&gt; to &lt;code&gt;USD&lt;/code&gt;, &lt;code&gt;hl&lt;/code&gt; to &lt;code&gt;en&lt;/code&gt;, and &lt;code&gt;gl&lt;/code&gt; to &lt;code&gt;us&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;addDays&lt;/code&gt; adds the trip duration to the dates of the departure window:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addDays&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isoDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;d&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseIsoDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;isoDate&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setUTCDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUTCDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;days&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="n"&gt;d&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toISOString&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;slice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&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;h3&gt;
  
  
  Making the request and handling provider errors
&lt;/h3&gt;

&lt;p&gt;After creating the query, the route fetches the Flights Calendar API response. It handles non-success HTTP responses separately from a provider error returned in a successfully parsed response. One specific provider error (exceeding its unique-combination limit) is returned with a message asking the user to narrow the departure range.&lt;/p&gt;

&lt;p&gt;If you set a departure window that produces too many date combinations, the Flights Calendar API returns an error that ends like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;... results in 400 unique combinations. This exceeds the maximum allowed limit of 200 combinations.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Every outbound date pairs with every return date, so two 20-day windows produce 20 × 20 = 400 combinations. The route catches this error and returns “Narrow your departure date range” so the traveler can narrow the window to 14 days or fewer.&lt;/p&gt;

&lt;p&gt;The fetch and error handling in the route determine whether calendar data can be used:&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;// After constructing `url` and `params`...&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nb"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${url}?${params}`&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="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;ok&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="n"&gt;errorText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;text&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="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SearchApi Calendar request failed:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;errorText&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="n"&gt;isCombinationLimit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;400&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="n"&gt;errorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"unique combinations"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt;
    &lt;span class="n"&gt;errorText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"maximum allowed limit"&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="n"&gt;isCombinationLimit&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;errorTitle&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Narrow your departure date range"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="s2"&gt;"This search creates too many date combinations for the flight provider. Choose a shorter departure window and try again."&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;400&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;return&lt;/span&gt; &lt;span class="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Failed to fetch fares from flight provider."&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;status&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="c1"&gt;// ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response message for the combination-limit error is more actionable and prompts the user to narrow their departure range. Other unsuccessful responses are logged and returned as provider-request failures. The client controller reads the route’s JSON response and moves the search into an error state if the response is unsuccessful or contains an&amp;nbsp;&lt;code&gt;error&lt;/code&gt;&amp;nbsp;field.&lt;/p&gt;

&lt;h3&gt;
  
  
  Extracting the calendar entries
&lt;/h3&gt;

&lt;p&gt;On a successful HTTP response, the route parses the JSON using the &lt;code&gt;SearchApiCalendarResponse&lt;/code&gt; type. It checks for a provider-level&amp;nbsp;&lt;code&gt;error&lt;/code&gt;, then retrieves the&amp;nbsp;&lt;code&gt;calendar&lt;/code&gt;&amp;nbsp;array. If the response doesn’t contain an array there, the route uses an empty array.&lt;/p&gt;

&lt;p&gt;The response parsing and calendar extraction establish the handoff to fare processing:&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="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SearchApiCalendarResponse&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nb"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"SearchApi returned error:"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;error&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="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;502&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;calendarItems&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;SearchApiCalendarItem&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;calendar&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;calendar&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="c1"&gt;// The calendar entries are processed below...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The types for the provider response and each calendar entry are defined in &lt;code&gt;frontend/src/lib/types.ts&lt;/code&gt; in the repo.&lt;/p&gt;

&lt;p&gt;A calendar item may include a departure date, return date, price, and flags such as &lt;code&gt;has_no_flights&lt;/code&gt;. Those raw entries are the input to Stage Three, where the route filters out unusable combinations, applies the requested duration, ranks fares, and returns the results for display.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stage 3: Rank the cheapest round-trip date pairs
&lt;/h2&gt;

&lt;p&gt;The Flights Calendar API returns date combinations, but not every one of the combinations is usable to the user. This section filters those combinations, converts them into the app’s &lt;code&gt;FlightFare&lt;/code&gt; format, ranks them by price, and renders the lowest fare first.&lt;/p&gt;

&lt;h3&gt;
  
  
  Filtering calendar entries and matching trip duration
&lt;/h3&gt;

&lt;p&gt;The calendar route filters out entries that have no departure or return dates, are marked as having no flights, and/or have a non-positive numeric fare. It also checks each remaining pair against the trip duration.&lt;/p&gt;

&lt;p&gt;Inside the calendar route, this filter keeps only entries with the requested duration:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;api/calendar/route.ts&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="c1"&gt;// Inside the POST handler, after extracting `data.calendar`...&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;validFares&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;FlightFare&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;calendarItems&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt; &lt;span class="n"&gt;is&lt;/span&gt; &lt;span class="nc"&gt;Required&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Pick&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;
    &lt;span class="nc"&gt;SearchApiCalendarItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"departure"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"return"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s2"&gt;"price"&lt;/span&gt;
  &lt;span class="o"&gt;&amp;gt;&amp;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;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departure&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;item&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="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&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="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;has_no_flights&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&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="k"&gt;typeof&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"number"&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;tripLength&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;dayDiff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departure&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;item&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="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;tripLength&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;duration&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="c1"&gt;// ...&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;dayDiff&lt;/code&gt;&amp;nbsp;uses UTC date arithmetic, so the duration comparison operates on calendar dates without local-time shifts:&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;dayDiff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;startIso&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;endIso&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseIsoDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;startIso&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="n"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;parseIsoDate&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;endIso&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="n"&gt;diffMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTime&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;return&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;round&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;diffMs&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;24&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;Applying this check to each pair ensures the displayed options fit the stay length the traveler requested.&lt;/p&gt;

&lt;h3&gt;
  
  
  Normalizing and ranking the fares
&lt;/h3&gt;

&lt;p&gt;The route sorts the remaining entries by the cheapest. It maps the entries to the &lt;code&gt;FlightFare&lt;/code&gt; shape the frontend expects. Each entry contans the route codes, departure and return dates, price (USD), and a Google Flights link in case a user wants to take a look at the listing.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;frontend/src/app/api/calendar/route.ts&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="c1"&gt;// Continuing the `validFares` pipeline...&lt;/span&gt;

&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sort&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;)&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;inspectUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sb"&gt;`https://www.google.com/travel/flights?q=Flights%20to%20${encodeURIComponent(
    destination
  )}%20from%20${encodeURIComponent(origin)}%20on%20${item.departure}%20through%20${item.return}`&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="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`${origin}-${destination}-${item.departure}-${item.return}-${index}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fromCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;toCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;fromCity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;toCity&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;destination&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;date&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;departure&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;returnDate&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item&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="n"&gt;priceUsd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;airline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;durationMinutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;stops&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;inspectUrl&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="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="nc"&gt;NextResponse&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;fares&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;validFares&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;totalFound&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;validFares&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;requestedDuration&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;duration&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;By sorting first, you put the cheapest fare at index 0. The route then returns the ranked fares alongside the count and requested duration. Airline, flight duration, and stop-count fields are included in the normalized shape, but are set to&amp;nbsp;&lt;code&gt;null&lt;/code&gt;&amp;nbsp;here because you don’t need them for this project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Showing the cheapest option
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;ResultsPanel&lt;/code&gt; renders the returned fares, passing the &lt;code&gt;isCheapest&lt;/code&gt; flag to the first item. The flag is used in the UI to designate the cheapest fare combination so it stands out from the other combinations. &lt;/p&gt;

&lt;p&gt;Each row shows the dates, round-trip price, and a link to inspect the fare on Google Flights.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;frontend/src/components/ResultsPanel.tsx&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="c1"&gt;// Inside ResultsPanel's successful-results branch...&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"success"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ResultsHeading&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ol&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mt-3 space-y-2.5"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;results&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="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fare&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FareRow&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fare&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;fare&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;fare&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;isCheapest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ol&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because the server already sorts the fares, the first row is the lowest-priced fare. &lt;code&gt;FareRow&lt;/code&gt; uses that flag to show its “Lowest fare” label and accent styling. &lt;/p&gt;

&lt;h3&gt;
  
  
  Handling loading, empty, and error states
&lt;/h3&gt;

&lt;p&gt;The results area shows the state of the search. The results area shows a four row-shaped skeletons when the request is in progress. And if a request is successful but no fares are returned, the results area UI explains that no matching flights were found for the user’s inputs.&lt;/p&gt;

&lt;p&gt;If the request fails completely, the results area shows an error panel with a retry button.&lt;/p&gt;

&lt;p&gt;The loading, empty, and error branches in &lt;code&gt;ResultsPanel&lt;/code&gt; make those outcomes visible to the traveler:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;frontend/src/components/ResultsPanel.tsx&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="c1"&gt;// Inside ResultsPanel's return statement...&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"loading"&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&amp;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt; &lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"sr-only"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nc"&gt;Searching&lt;/span&gt; &lt;span class="n"&gt;flight&lt;/span&gt; &lt;span class="n"&gt;calendar&lt;/span&gt; &lt;span class="n"&gt;fares&lt;/span&gt;…
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;p&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;ResultsHeading&lt;/span&gt; &lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;query&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ol&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mt-3 space-y-2.5"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&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="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&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="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;FareRowSkeleton&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;index&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="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;ol&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StatePanel&lt;/span&gt;
    &lt;span class="n"&gt;tone&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"alert"&lt;/span&gt;
    &lt;span class="n"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;AlertTriangleIcon&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"size-6"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errorTitle&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;"We could not load flight fares"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;action&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Button&lt;/span&gt; &lt;span class="n"&gt;variant&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"quiet"&lt;/span&gt; &lt;span class="n"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;onRetry&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"mt-2"&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nc"&gt;Try&lt;/span&gt; &lt;span class="n"&gt;search&lt;/span&gt; &lt;span class="n"&gt;again&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&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="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;errorMessage&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&gt;"Something went wrong while querying Google Flights. Please try again."&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StatePanel&lt;/span&gt;&lt;span class="o"&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="s2"&gt;"success"&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;StatePanel&lt;/span&gt;
    &lt;span class="n"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;CalendarIcon&lt;/span&gt; &lt;span class="n"&gt;className&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"size-6"&lt;/span&gt; &lt;span class="o"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"No flights found for this window"&lt;/span&gt;
  &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="cm"&gt;/* The panel describes the searched route, dates, and duration. */&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="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;StatePanel&lt;/span&gt;&lt;span class="o"&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The skeleton, empty, and error states distinguish “still searching,” “no matching dates,” and “the search failed” rather than leaving the results area blank. The error panel’s retry action calls back into the controller, which reruns the active query.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Bringing the three stages together&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Here’s the finished flow: &lt;/p&gt;

&lt;p&gt;A user’s inputs (route, departure window, and trip duration) are collected and sent to the &lt;code&gt;api/calendar&lt;/code&gt; API route to get round-trip fare combinations. The returned date pairs are sorted by price in an ascending order. &lt;/p&gt;

&lt;p&gt;Users can inspect each listing on Google Flights. &lt;/p&gt;

&lt;p&gt;The UI shows the progress of a request and tells the user when there are no available fares or when a search fails.&lt;/p&gt;

&lt;p&gt;Here’s a real run for a user who wants to travel to Manchester from San Francisco between the 1st and 7th of November and stay for 10 days:&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwo3qpngd18042dts70rd.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fwo3qpngd18042dts70rd.png" alt="demo" width="800" height="532"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;“07 Nov – 17 Nov” at $798 is the cheapest option.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Conclusion: Making flexible travel dates easier to compare
&lt;/h2&gt;

&lt;p&gt;The Cheapest-Day-to-Fly Finder turns flexible travel plans into a ranked set of round-trip pairs. Users enter a route, a departure window, and a trip duration; the app uses SearchApi’s Google Flights Location Search and Calendar endpoints to find matching fare combinations, then sorts them by price. &lt;/p&gt;

&lt;p&gt;The app’s main idea is to make it easy to find cheap flight options when you aren't sure of exactly when to travel. So, you no longer have to manually check every possible flight date; with only a few inputs, you get sorted round-trip pairs.&lt;/p&gt;

&lt;p&gt;You can't use the app to book a flight, though. It's for narrowing your search. For each round-trip pair, there's a link to inspect it on Google Flights.&lt;/p&gt;

&lt;p&gt;Run the finder on your own route and compare the lowest fare with what Google Flights shows. You can create a free SearchApi account to get 100 free searches.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>nextjs</category>
      <category>webdev</category>
      <category>webscraping</category>
    </item>
    <item>
      <title>How to Write a Developer Tutorial That People Actually Finish</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Mon, 09 Nov 2026 17:37:42 +0000</pubDate>
      <link>https://dev.to/studio1hq/how-to-write-a-developer-tutorial-that-people-actually-finish-39ck</link>
      <guid>https://dev.to/studio1hq/how-to-write-a-developer-tutorial-that-people-actually-finish-39ck</guid>
      <description>&lt;h1&gt;
  
  
  How to Write a Developer Tutorial That People Actually Finish
&lt;/h1&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;A developer tutorial gets finished when it has one clear outcome, a fast first win, and code that works the first time.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick one outcome, name it in the title, and show the finished result in the first screen.&lt;/li&gt;
&lt;li&gt;Get readers to something visible in the first five minutes. Keep every step small enough to check.&lt;/li&gt;
&lt;li&gt;Cut the theory and link to it. A tutorial teaches by doing, and explanations belong on another page.&lt;/li&gt;
&lt;li&gt;Test the whole thing on a clean machine. Put the version and date at the top.&lt;/li&gt;
&lt;li&gt;Measure drop-off by step, not by page views.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why does tutorial quality matter more now?
&lt;/h2&gt;

&lt;p&gt;Developers still learn from docs first, but they now have a faster option sitting next to them. In the &lt;a href="https://stackoverflow.co/company/press/archive/stack-overflow-2025-developer-survey" rel="noopener noreferrer"&gt;Stack Overflow 2025 Developer Survey results&lt;/a&gt;, technical documentation was the top resource for learning to code at 68%. Yet 44% of developers now use AI tools to learn too, up from 37% the year before.&lt;/p&gt;

&lt;p&gt;So your tutorial competes with a chatbot that answers in two seconds. If your reader has to guess, wait, or fix your typo, they close the tab and ask the bot.&lt;/p&gt;

&lt;p&gt;This guide shows how to write a tutorial that people read to the end. Every number links to its source. One honest note: I could not find a trustworthy industry-wide completion rate for tutorials, so I won't make one up. What we do have is solid data on why developers get stuck, and it all points the same way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a developer tutorial, and how is it different from a how-to guide?
&lt;/h2&gt;

&lt;p&gt;A developer tutorial is a guided lesson where the reader builds one small, working thing and learns by doing it. A how-to guide is for someone who already knows what they want. Most weak tutorials are really a mix of both.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.diataxis.fr/start-here/" rel="noopener noreferrer"&gt;Diátaxis&lt;/a&gt;, a documentation framework many teams use, splits docs into four kinds:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Reader's mood&lt;/th&gt;
&lt;th&gt;Example title&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Tutorial&lt;/td&gt;
&lt;td&gt;"I want to learn"&lt;/td&gt;
&lt;td&gt;Build a link shortener from scratch&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How-to guide&lt;/td&gt;
&lt;td&gt;"I have a job to do"&lt;/td&gt;
&lt;td&gt;How to rotate an API key&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reference&lt;/td&gt;
&lt;td&gt;"I need one fact"&lt;/td&gt;
&lt;td&gt;POST /links parameters&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Explanation&lt;/td&gt;
&lt;td&gt;"I want to understand"&lt;/td&gt;
&lt;td&gt;Why we use signed URLs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The &lt;a href="https://diataxis.fr/tutorials/" rel="noopener noreferrer"&gt;Diátaxis tutorial page&lt;/a&gt; opens with a rule that sounds odd at first: don't try to teach. Your job is to give the reader an experience they can learn from. Once you write that way, the rest gets easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do developers quit tutorials?
&lt;/h2&gt;

&lt;p&gt;Developers quit when something is missing, wrong, or slow, and they scan instead of reading. Here is what the data says.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What was measured&lt;/th&gt;
&lt;th&gt;Result&lt;/th&gt;
&lt;th&gt;Source&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Teams reporting documentation gaps&lt;/td&gt;
&lt;td&gt;55% of respondents&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.businesswire.com/news/home/20251008162423/en" rel="noopener noreferrer"&gt;Postman 2025 State of the API&lt;/a&gt; (5,700+ developers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Biggest frustration with AI tools&lt;/td&gt;
&lt;td&gt;66% said "almost right, but not quite"&lt;/td&gt;
&lt;td&gt;&lt;a href="https://survey.stackoverflow.co/2025/" rel="noopener noreferrer"&gt;Stack Overflow 2025 survey&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;How people read a new web page&lt;/td&gt;
&lt;td&gt;79% scan, 16% read word by word&lt;/td&gt;
&lt;td&gt;
&lt;a href="https://www.nngroup.com/articles/how-users-read-on-the-web/" rel="noopener noreferrer"&gt;Nielsen Norman Group&lt;/a&gt; (a 1997 study, but the behavior has held up)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed of a first API call&lt;/td&gt;
&lt;td&gt;1.7x faster with a ready-made collection from the publisher&lt;/td&gt;
&lt;td&gt;&lt;a href="https://blog.postman.com/improve-your-time-to-first-api-call-by-20x/" rel="noopener noreferrer"&gt;Postman&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Three things follow from this.&lt;/p&gt;

&lt;p&gt;Missing or sloppy docs are still common, so a tutorial that simply works stands out. AI answers that are almost right waste people's time, and a tested tutorial is the fix for that. And readers scan, so your headings, code blocks, and expected output carry more weight than your paragraphs.&lt;/p&gt;

&lt;p&gt;Postman's team calls time to first call the most important API metric. The idea applies to any tutorial: the sooner someone sees something work, the more likely they are to keep going.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to write a developer tutorial: a 9-step playbook
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Pick one outcome and put it in the title
&lt;/h3&gt;

&lt;p&gt;Name the thing the reader will build or do. "Build a background job queue from scratch" beats "Introduction to queues." If you can't say the outcome in one line, the tutorial is too big.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Show the finished result in the first two sentences
&lt;/h3&gt;

&lt;p&gt;Tell people what they will have at the end, how long it takes, and what they need. Here is the difference.&lt;/p&gt;

&lt;p&gt;A weak opening: &lt;em&gt;In this tutorial, you will learn about queues, workers, and retries.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;A strong one: &lt;em&gt;By the end, you will have a small working app that runs a job in the background and prints "Job done" in your terminal. It takes about 20 minutes. You need a terminal and the language runtime you tested with, at the version you tested.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The strong version gives the reader a finish line. It also works as a standalone answer if a search engine or an AI assistant quotes it.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Keep prerequisites short and exact
&lt;/h3&gt;

&lt;p&gt;List the tools and versions you tested with. Link to install pages instead of explaining installs. Every extra prerequisite loses a few readers before step one.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Make step one produce something visible
&lt;/h3&gt;

&lt;p&gt;Don't spend the first five minutes on theory or config. Get a command running and a result on screen early. Diátaxis calls this delivering visible results early and often. Every step should produce a result the reader can see, even a small one.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. One action per step, and say what they should see
&lt;/h3&gt;

&lt;p&gt;This is the pattern to use for every step:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 3: Start the worker

Run this in a second terminal:

    [your start command]

You should see:

    Worker ready, waiting for jobs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The "You should see" line does most of the work. It lets readers catch a mistake right away instead of five steps later.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Cut explanations and link out
&lt;/h3&gt;

&lt;p&gt;A tutorial is not the place for long explanations. Say what to do, say what happens, move on. Put the "why" in a separate explainer and link to it. Readers who want it will click. Readers who don't will keep going.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Give the full working code in one place
&lt;/h3&gt;

&lt;p&gt;Link a repo or show the complete file at the end. Include imports and setup, with no "..." in the middle. If someone gets lost at step six, they can compare against the finished version and fix it themselves.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Show the errors people will hit
&lt;/h3&gt;

&lt;p&gt;You can find where people get stuck by watching a few people test the tutorial. Put the exact error text in the tutorial with a one-line fix. People paste error messages straight into search and chat tools, so exact text also helps readers find you.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Test it on a clean machine, then date it
&lt;/h3&gt;

&lt;p&gt;Run every step in a fresh container or a new user account. Your own laptop hides missing dependencies and old config. Then add the date and the tool versions at the top. A tutorial with no date reads like a risk.&lt;/p&gt;

&lt;h2&gt;
  
  
  How long should a developer tutorial be?
&lt;/h2&gt;

&lt;p&gt;As long as the outcome needs, and no longer. If it can't be finished in one sitting, split it into parts, each with its own working result.&lt;/p&gt;

&lt;p&gt;For search and AI answers, section size matters too. Studio1 pulled together data in &lt;a href="https://www.studio1hq.com/blog/developer-docs-as-aeo-asset" rel="noopener noreferrer"&gt;its guide to developer docs and AEO&lt;/a&gt; showing that sections of roughly 120 to 180 words between headings did better than very short fragments. The same guide cites Ahrefs finding that 44.2% of AI citations came from the first 30% of a page, so put your best material up top.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you make a tutorial work for SEO and AI answers?
&lt;/h2&gt;

&lt;p&gt;Keep it simple. Google's own &lt;a href="https://developers.google.com/search/docs/appearance/ai-features" rel="noopener noreferrer"&gt;guide to AI features and your website&lt;/a&gt; says there are no additional requirements to appear in AI Overviews or AI Mode. A page needs to be indexed and eligible to show with a snippet, and the usual SEO basics apply. The basics do the work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Put the task in the title, in the words a developer would type. "How to build a webhook handler in Python" beats "Webhooks, Part 2."&lt;/li&gt;
&lt;li&gt;Use question-style headings where they fit, like the ones on this page.&lt;/li&gt;
&lt;li&gt;Answer first. The opening should still make sense if it is pulled out alone.&lt;/li&gt;
&lt;li&gt;Keep code and output as plain text on the page, not in screenshots. Google also lists text availability as a basic.&lt;/li&gt;
&lt;li&gt;Show an updated date, and keep it honest.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Studio1's data also showed pages updated in the last three months averaged 6 ChatGPT citations, against 3.6 for older pages. Those are links between traits and citations, not proof of cause. Still, it is a good reason to review your top tutorials every quarter.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can you template tutorials for programmatic SEO?
&lt;/h2&gt;

&lt;p&gt;Yes, with one rule: a template gives you the skeleton, not the content. "Build a job queue in Python," "in Go," and "in Ruby" can share the same structure. But each one needs its own tested code, its own errors, and its own output.&lt;/p&gt;

&lt;p&gt;If two tutorials would read the same with one word swapped, don't publish both. Search engines and readers will skip the second one.&lt;/p&gt;

&lt;h2&gt;
  
  
  How do you know if people finish your tutorial?
&lt;/h2&gt;

&lt;p&gt;Page views won't tell you. Track where people stop, not how many arrive. Try these instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Step-level drop-off. Track scroll depth or anchor clicks by heading. If half your readers vanish at step four, step four is broken.&lt;/li&gt;
&lt;li&gt;Copy button clicks on your code blocks, by step.&lt;/li&gt;
&lt;li&gt;Time to first success. If your tutorial ends in an API call, measure the gap between landing and that call. &lt;a href="https://blog.postman.com/the-most-important-api-metric-is-time-to-first-call/" rel="noopener noreferrer"&gt;Postman's write-up on time to first call&lt;/a&gt; suggests using analytics for the objective number and usability tests for the human one.&lt;/li&gt;
&lt;li&gt;Five real people. Watch five developers do it on a call, without helping. You will find problems in 20 minutes that analytics would take months to show.&lt;/li&gt;
&lt;li&gt;Comments and issues. If the same error shows up twice, it belongs in the tutorial.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One warning: don't improve a time-to-success number by hiding the hard parts. You just move the friction to a later step.&lt;/p&gt;

&lt;h2&gt;
  
  
  What mistakes make developers abandon tutorials?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Starting with history, concepts, or architecture before anything runs.&lt;/li&gt;
&lt;li&gt;Skipping the expected output, so readers can't tell if they're on track.&lt;/li&gt;
&lt;li&gt;Code with gaps, or code that only works on your machine.&lt;/li&gt;
&lt;li&gt;Mixing two goals, like teaching a concept and solving a task on the same page.&lt;/li&gt;
&lt;li&gt;No versions and no date.&lt;/li&gt;
&lt;li&gt;Offering three ways to do the same thing. In a tutorial, pick one.&lt;/li&gt;
&lt;li&gt;Ending with nothing. Say what they built and link to the next page.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Pre-publish checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Does the title name one outcome?&lt;/li&gt;
&lt;li&gt;Do the first two sentences say what the reader will have at the end?&lt;/li&gt;
&lt;li&gt;Does step one show a visible result?&lt;/li&gt;
&lt;li&gt;Does every step say what the reader should see?&lt;/li&gt;
&lt;li&gt;Is the full working code in one place?&lt;/li&gt;
&lt;li&gt;Did you run it on a clean machine this week?&lt;/li&gt;
&lt;li&gt;Are the version and the date at the top?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is the best structure for a developer tutorial?
&lt;/h3&gt;

&lt;p&gt;Outcome first, then prerequisites, then small steps that each end with visible output, then the full code and a pointer to what comes next. Keep theory on separate pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should a tutorial explain why things work?
&lt;/h3&gt;

&lt;p&gt;Barely. Diátaxis says a tutorial is for doing, and explanation belongs elsewhere. One sentence of context per step is plenty. Link to a deeper page for anyone who wants more.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should I use video or text?
&lt;/h3&gt;

&lt;p&gt;Text, with video as an extra. In the &lt;a href="https://survey.stackoverflow.co/2025/" rel="noopener noreferrer"&gt;Stack Overflow 2025 survey&lt;/a&gt;, people learning to code leaned on YouTube more than working professionals did (70% vs 60%). But text can be searched, copied, and quoted, so the written version should stand on its own.&lt;/p&gt;

&lt;h3&gt;
  
  
  How often should I update a tutorial?
&lt;/h3&gt;

&lt;p&gt;Check your most-read ones at least every three months, and any time a tool you use ships a major version. Only change the date when you actually changed the page.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is a quickstart the same as a tutorial?
&lt;/h3&gt;

&lt;p&gt;Not quite. A quickstart gets someone to a first success as fast as possible. A tutorial is a longer guided build. A good quickstart can lead into a tutorial, but they do different jobs.&lt;/p&gt;

</description>
      <category>documentation</category>
      <category>tutorial</category>
      <category>writing</category>
    </item>
    <item>
      <title>How to Grow an Open Source Project: 12 Steps That Bring Real Users and Contributors</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Thu, 05 Nov 2026 13:23:21 +0000</pubDate>
      <link>https://dev.to/studio1hq/how-to-grow-an-open-source-project-12-steps-that-bring-real-users-and-contributors-5ef9</link>
      <guid>https://dev.to/studio1hq/how-to-grow-an-open-source-project-12-steps-that-bring-real-users-and-contributors-5ef9</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;To grow an open source project, help people quickly understand its value, get started with minimal effort, and make their first contribution. Reach users where they already gather, respond promptly, and recognize everyone who contributes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Most projects stall because people cannot tell what the project does or how to start, not because the code is weak.&lt;/li&gt;
&lt;li&gt;A clear README, a short quickstart, and labeled beginner issues do more than any launch post.&lt;/li&gt;
&lt;li&gt;A launch on Hacker News can bring a burst of stars, but replies, docs, and trust keep people around.&lt;/li&gt;
&lt;li&gt;Plan for the maintainers too. Burnout ends more projects than bad code does.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Developers are building at a pace the world has never seen. GitHub's &lt;a href="https://github.blog/news-insights/octoverse/octoverse-a-new-developer-joins-github-every-second-as-ai-leads-typescript-to-1/" rel="noopener noreferrer"&gt;Octoverse 2025 report&lt;/a&gt; says a new developer joined GitHub every second on average, and about 230 new repositories were created every minute. It also says 63% of all repositories on GitHub are public or open source.&lt;/p&gt;

&lt;p&gt;So your project is not just competing with other good ideas. It is competing with a flood of them, every minute of every day.&lt;/p&gt;

&lt;p&gt;This guide walks through what actually helps an open source project grow, in plain steps you can start today. Every number links to where it came from.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does it mean to grow an open source project?
&lt;/h2&gt;

&lt;p&gt;Growing an open source project means more people use it, more people help build it, and a few of them stay long enough to share the load. Stars are a nice sign, but they are not the goal.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://opensource.guide/building-community/" rel="noopener noreferrer"&gt;Open Source Guides&lt;/a&gt;, written by GitHub, describe this as a funnel. People start as users, some become contributors, and a few become maintainers. Your job is to remove friction at every step so each person finds an easy first win.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Stage&lt;/th&gt;
&lt;th&gt;What it looks like&lt;/th&gt;
&lt;th&gt;What moves people forward&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Visitor&lt;/td&gt;
&lt;td&gt;Lands on your repo and decides in seconds&lt;/td&gt;
&lt;td&gt;A clear one line pitch and a good README&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;User&lt;/td&gt;
&lt;td&gt;Installs and tries it&lt;/td&gt;
&lt;td&gt;A working quickstart and examples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contributor&lt;/td&gt;
&lt;td&gt;Files an issue or sends a fix&lt;/td&gt;
&lt;td&gt;Labeled beginner tasks and fast replies&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Maintainer&lt;/td&gt;
&lt;td&gt;Reviews, releases, helps others&lt;/td&gt;
&lt;td&gt;Trust, credit, and shared ownership&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Keep that table in mind. Every step below fits into one of those rows.&lt;/p&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fudqx06s5343ehtbyuil9.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fudqx06s5343ehtbyuil9.png" alt="open-source-guide" width="800" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to grow an open source project: 12 steps
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Say what it does in one sentence
&lt;/h3&gt;

&lt;p&gt;Before anything else, you need a sentence a stranger can repeat. Who is it for, and what problem does it fix?&lt;/p&gt;

&lt;p&gt;Open Source Guides suggest asking yourself what makes the project different and why you built it, then writing from the point of view of a user, not the builder. Try finishing this line: "My project helps X do Y without Z." If you cannot finish it, nobody else will be able to either.&lt;/p&gt;

&lt;p&gt;Put that sentence at the top of your README, in your GitHub description, on your website, and in every post you write.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Make the README do the selling
&lt;/h3&gt;

&lt;p&gt;Your README is your landing page. Treat it that way.&lt;/p&gt;

&lt;p&gt;The numbers explain why. In GitHub's 2017 Open Source Survey, &lt;a href="https://sdtimes.com/code/github-releases-2017-open-source-survey/" rel="noopener noreferrer"&gt;93% of respondents said they had run into incomplete or outdated documentation&lt;/a&gt;. The same survey found that &lt;a href="https://adtmag.com/Articles/2017/06/05/open-source-survey.aspx" rel="noopener noreferrer"&gt;60% of contributors say they rarely or never help with docs&lt;/a&gt;. That is a big gap, and it is your chance to stand out.&lt;/p&gt;

&lt;p&gt;A README that works has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The one-sentence pitch at the top.&lt;/li&gt;
&lt;li&gt;A short code sample or screenshot showing the result.&lt;/li&gt;
&lt;li&gt;Install steps that take under a minute.&lt;/li&gt;
&lt;li&gt;A link to full docs.&lt;/li&gt;
&lt;li&gt;The license.&lt;/li&gt;
&lt;li&gt;A line on how to get help and how to contribute.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Open Source Guides has &lt;a href="https://opensource.guide/starting-a-project/#writing-a-readme" rel="noopener noreferrer"&gt;a simple walkthrough for writing a README&lt;/a&gt; if you want a starting point.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Add a license, a contributing file, and a code of conduct
&lt;/h3&gt;

&lt;p&gt;These three files tell people it is safe to use your work and safe to join in. The same survey coverage notes that licenses are the most valued type of documentation for both users and contributors.&lt;/p&gt;

&lt;p&gt;Without a license, many companies will not touch your code. Without a contributing guide, newcomers guess, and guessing is scary. Without a code of conduct, you have no clear way to handle bad behavior when it shows up.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Give the project one home
&lt;/h3&gt;

&lt;p&gt;People need one link to remember. A GitHub repo works at the start. A small website works better as you grow.&lt;/p&gt;

&lt;p&gt;Open Source Guides quotes Adrian Holovaty, co-creator of Django, saying the website was one of the best things the team did early on. You do not need anything fancy. &lt;a href="https://pages.github.com/" rel="noopener noreferrer"&gt;GitHub Pages&lt;/a&gt; is free and fine. What matters is that the site has your pitch, the quickstart, examples, and docs in one place.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Make the first five minutes work
&lt;/h3&gt;

&lt;p&gt;A visitor who cannot get a working result in five minutes usually leaves and does not come back.&lt;/p&gt;

&lt;p&gt;Test your own quickstart on a clean machine. Better still, ask a friend who has never seen the project to try it while you watch silently. Fix every spot where they pause.&lt;/p&gt;

&lt;p&gt;Then add:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A starter template or example repo people can clone.&lt;/li&gt;
&lt;li&gt;Copy and paste code that runs without edits.&lt;/li&gt;
&lt;li&gt;The exact text of the most common errors, with fixes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Studio1 has written about &lt;a href="https://www.studio1hq.com/blog/common-mistakes-developer-products" rel="noopener noreferrer"&gt;why poor onboarding and thin docs sink developer products&lt;/a&gt;. The same lessons apply to open source.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Label good first issues
&lt;/h3&gt;

&lt;p&gt;Most people who want to help do not know where to start. Show them.&lt;/p&gt;

&lt;p&gt;Use the "good first issue" and "help wanted" labels on tasks a newcomer can finish. GitHub's own docs say it uses an algorithm to find approachable issues and show them in places across the site, and that adding the label can raise the chance yours get shown. The &lt;a href="https://contribute.cncf.io/resources/templates/issue-labels" rel="noopener noreferrer"&gt;CNCF issue label guide&lt;/a&gt; adds a good test: a new person should be able to claim the task and send an acceptable pull request without having to ask for help.&lt;/p&gt;

&lt;p&gt;Write each beginner issue so it stands on its own. Say why it matters, which files to look at, and what done looks like.&lt;/p&gt;

&lt;p&gt;Also, keep a few easy bugs unfixed on purpose. Open Source Guides suggest using small, non-urgent bugs as a way to bring in new contributors instead of fixing them yourself.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Reply fast, especially to first timers
&lt;/h3&gt;

&lt;p&gt;This one costs nothing and matters a lot.&lt;/p&gt;

&lt;p&gt;Open Source Guides point to &lt;a href="https://opensource.guide/building-community/" rel="noopener noreferrer"&gt;a Mozilla study&lt;/a&gt; showing that contributors who got a code review within 48 hours came back far more often. They also warn that if you leave an issue sitting for a month, people usually forget your project.&lt;/p&gt;

&lt;p&gt;The numbers on why this matters are not pretty. One analysis by the team at Multitudes found that &lt;a href="https://levelup.gitconnected.com/how-to-create-a-better-first-time-contributor-experience-for-your-open-source-project-27300d6085ad" rel="noopener noreferrer"&gt;around 70% of contributors are one-time contributors&lt;/a&gt;. A friendly, quick reply is how you turn a few of them into regulars.&lt;/p&gt;

&lt;p&gt;You do not need a full review in two days. A short note like "Thanks, I will look this week" counts. Track it, too. The Linux Foundation's &lt;a href="https://insights.linuxfoundation.org/docs/metrics/development" rel="noopener noreferrer"&gt;Insights tool&lt;/a&gt; lists median time to first review as a health signal for exactly this reason.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Launch where developers already hang out
&lt;/h3&gt;

&lt;p&gt;You do not have to launch loudly, but you do have to tell people. Open Source Guides say plainly that you have to spread the word instead of hoping others find you.&lt;/p&gt;

&lt;p&gt;Researchers looked at how the 100 most starred GitHub projects promote themselves. The paper, &lt;a href="https://arxiv.org/abs/1908.04219" rel="noopener noreferrer"&gt;How Do Developers Promote Open Source Projects?&lt;/a&gt;, found that Twitter (now X), user meetups, and blogs were the most common channels. It also showed that a successful Hacker News post gave projects a clear jump in stars.&lt;/p&gt;

&lt;p&gt;More recent work agrees. A 2025 study of &lt;a href="https://arxiv.org/abs/2506.12643" rel="noopener noreferrer"&gt;1,814 AI repositories shared on Hacker News&lt;/a&gt; saw a significant rise in forks, stars, and contributors afterward. Another paper tracked &lt;a href="https://arxiv.org/abs/2511.04453" rel="noopener noreferrer"&gt;138 repository launches&lt;/a&gt; and found an average gain of 121 stars in the first day, 189 in two days, and 289 in a week. It also found the "Show HN" tag gave no statistical edge once other factors were counted, while the time of posting did matter.&lt;/p&gt;

&lt;p&gt;Treat those as averages from AI and developer tool launches, not a promise. Your result depends on the idea and the post.&lt;/p&gt;

&lt;p&gt;How to launch without being annoying:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pick two or three places where your exact users hang out, not ten.&lt;/li&gt;
&lt;li&gt;Say who it is for and what you want feedback on.&lt;/li&gt;
&lt;li&gt;Show the working result first, then the story.&lt;/li&gt;
&lt;li&gt;Stay in the thread and answer every comment.&lt;/li&gt;
&lt;li&gt;If nobody notices, try a new angle in a month. Open Source Guides note that many launches take months or years to catch on.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  9. Write content people actually search for
&lt;/h3&gt;

&lt;p&gt;Most developers do not find projects by luck. They search for a problem, or they ask an assistant.&lt;/p&gt;

&lt;p&gt;In the 2025 Stack Overflow Developer Survey, &lt;a href="https://survey.stackoverflow.co/2025/ai" rel="noopener noreferrer"&gt;50.6% of professional developers said they use AI tools every day&lt;/a&gt;. So your pages need to work for Google and for AI answers.&lt;/p&gt;

&lt;p&gt;Write the pages your users would search for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;How-to guides&lt;/strong&gt; for each main task ("How to add auth to a Next.js app with X").&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Comparisons&lt;/strong&gt; that are honest about where another tool fits better.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Migration guides&lt;/strong&gt; for people leaving a competitor.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error fixes&lt;/strong&gt; with the exact error message in the title.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put the answer in the first two sentences. Keep every section understandable on its own, so a search engine or assistant can lift it out. Studio1 goes deeper into &lt;a href="https://www.studio1hq.com/blog/developer-docs-as-aeo-asset" rel="noopener noreferrer"&gt;Developer Docs as Your Best AEO Asset&lt;/a&gt; and &lt;a href="https://www.studio1hq.com/blog/how-to-get-your-tool-recommended-by-chatgpt-perplexity-google" rel="noopener noreferrer"&gt;How to Get Your Tool Recommended by ChatGPT, Perplexity, and Google&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. Help other people before you ask for anything
&lt;/h3&gt;

&lt;p&gt;The fastest way to be known is to be useful somewhere else.&lt;/p&gt;

&lt;p&gt;Open Source Guides suggest answering questions in forums where your users ask for help, and mentioning your project only when it truly fits. They also suggest contributing to projects near yours. The guide shares a story from the maintainer of urllib3, who said the library became so popular largely because requests bundled it.&lt;/p&gt;

&lt;p&gt;Practical ways to do this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Answer questions on Stack Overflow, Reddit, and Discord with real fixes.&lt;/li&gt;
&lt;li&gt;Send a pull request to a related project.&lt;/li&gt;
&lt;li&gt;Thank people who write about your project, and share their posts.&lt;/li&gt;
&lt;li&gt;Speak at a local meetup. It is a gentle way to start, and the people in the room are real users.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  11. Share ownership and give credit
&lt;/h3&gt;

&lt;p&gt;People stay where they feel their work counts.&lt;/p&gt;

&lt;p&gt;Open Source Guides list several easy moves: keep a CONTRIBUTORS or AUTHORS file, thank people by name in release notes or a newsletter, give regular contributors commit access, and move the repo to a GitHub organization with at least one backup admin. They also note that most projects have only one or two maintainers doing most of the work, so the earlier you invite help, the better.&lt;/p&gt;

&lt;p&gt;Public credit is cheap, and it works. Projects like Rust do it with a weekly newsletter that names contributors.&lt;/p&gt;

&lt;h3&gt;
  
  
  12. Protect the people who keep it running
&lt;/h3&gt;

&lt;p&gt;A growing project means more issues, more questions, and more pressure. If you do not plan for that, you burn out.&lt;/p&gt;

&lt;p&gt;Tidelift's 2024 survey of maintainers found that &lt;a href="https://www.theregister.com/2024/09/18/open_source_maintainers_underpaid/" rel="noopener noreferrer"&gt;60% describe themselves as unpaid hobbyists&lt;/a&gt;, and &lt;a href="https://sdtimes.com/open-source/the-state-of-open-source-maintainers/" rel="noopener noreferrer"&gt;60% have quit or thought about quitting&lt;/a&gt;. Tidelift's own breakdown also says 78% of unpaid maintainers spend ten hours or less a week on their projects.&lt;/p&gt;

&lt;p&gt;That means your project probably runs on a few hours of someone's spare time. Build for that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Move all help into public channels, such as issues or discussions, so answers help everyone, and you are not stuck in private messages.&lt;/li&gt;
&lt;li&gt;Set office hours. The Kubernetes kops team does this every other week to help newcomers.&lt;/li&gt;
&lt;li&gt;Write down what you will and will not accept, and say no kindly.&lt;/li&gt;
&lt;li&gt;Add a second maintainer before you need one.&lt;/li&gt;
&lt;li&gt;Look into funding early. Tidelift reports that income most often comes from donations such as GitHub Sponsors (25%) or from employers who include open source work in a salary (24%).&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How do you know your open source project is growing?
&lt;/h2&gt;

&lt;p&gt;Stars are easy to see, but they do not tell you whether anyone is using or helping. Watch a few numbers that do.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What to track&lt;/th&gt;
&lt;th&gt;Why it matters&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Installs or downloads per month&lt;/td&gt;
&lt;td&gt;Shows real use, not just interest&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;New issues from people you do not know&lt;/td&gt;
&lt;td&gt;A sign the project is being tried&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;First time contributors per month&lt;/td&gt;
&lt;td&gt;Shows whether your doors are open&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Contributors who come back&lt;/td&gt;
&lt;td&gt;Shows whether they felt welcome&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Median time to first reply&lt;/td&gt;
&lt;td&gt;The number you control most&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Visits to your docs from search&lt;/td&gt;
&lt;td&gt;Shows your content is being found&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Check them once a month and write the numbers down. Small, steady gains beat one big spike.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can programmatic SEO help an open source project?
&lt;/h2&gt;

&lt;p&gt;Yes, if you have real facts behind every page. Programmatic SEO (pSEO) means building many pages from one template and a set of true details. For open source, the natural pages are the ones you already have material for.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Page type&lt;/th&gt;
&lt;th&gt;Example question it answers&lt;/th&gt;
&lt;th&gt;What you need&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Error page&lt;/td&gt;
&lt;td&gt;What does "ECONNRESET" mean in our client and how do I fix it?&lt;/td&gt;
&lt;td&gt;Exact message, cause, working fix&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Integration page&lt;/td&gt;
&lt;td&gt;How do I use our library with Express?&lt;/td&gt;
&lt;td&gt;Tested steps and code&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Migration page&lt;/td&gt;
&lt;td&gt;How do I move from Library X to ours?&lt;/td&gt;
&lt;td&gt;Side by side code, before and after&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Comparison page&lt;/td&gt;
&lt;td&gt;Ours vs Library X for caching&lt;/td&gt;
&lt;td&gt;Honest numbers and trade offs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Release page&lt;/td&gt;
&lt;td&gt;What changed in version 3?&lt;/td&gt;
&lt;td&gt;Dated notes and upgrade steps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;One rule keeps this safe. Do not publish a page until it has facts that only apply to that page. If a page would read the same with one word swapped, search engines and AI tools will skip it. Google also says there is &lt;a href="https://developers.google.com/search/docs/appearance/ai-features" rel="noopener noreferrer"&gt;no special markup needed to appear in its AI features&lt;/a&gt;. Pages just need to be indexed and useful.&lt;/p&gt;

&lt;h2&gt;
  
  
  What mistakes slow down open source growth?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Launching with a weak README.&lt;/strong&gt; The visitor leaves before you can explain.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Hiding the best help in private chats.&lt;/strong&gt; Nobody else can learn from it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ignoring first pull requests.&lt;/strong&gt; Many first-timers never return after a silent reply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Doing every easy fix yourself.&lt;/strong&gt; You lose the chance to invite someone new.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Posting in ten places and following up in none.&lt;/strong&gt; Two good threads beat ten ignored ones.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Chasing stars over use.&lt;/strong&gt; Stars fade. Installs and contributors build a project.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Skipping docs updates.&lt;/strong&gt; Old docs do quiet damage to trust.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A simple 30 day plan
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Week&lt;/th&gt;
&lt;th&gt;Focus&lt;/th&gt;
&lt;th&gt;Done when&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;One sentence pitch, README rewrite, license, contributing file&lt;/td&gt;
&lt;td&gt;A stranger can explain your project back to you&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2&lt;/td&gt;
&lt;td&gt;Quickstart test with a new user, starter template, error fixes in docs&lt;/td&gt;
&lt;td&gt;Someone gets a working result in under five minutes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;Ten labeled beginner issues, public channel for help, reply rules&lt;/td&gt;
&lt;td&gt;A new contributor can pick a task without asking&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;Launch in two chosen communities, publish one how-to and one comparison&lt;/td&gt;
&lt;td&gt;You answered every comment within a day&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Then repeat the cycle. Growth comes from small habits you keep up.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently asked questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  How long does it take to grow an open source project?
&lt;/h3&gt;

&lt;p&gt;Often months or years. Open Source Guides say some of today's most popular projects took years to reach high activity. Plan for steady effort, and expect early progress to be small.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I get my first contributors?
&lt;/h3&gt;

&lt;p&gt;Label beginner issues, write a clear contributing guide, and reply within a couple of days. Contributors rarely arrive on their own. Invite them in public and thank them by name.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do GitHub stars matter?
&lt;/h3&gt;

&lt;p&gt;They help people trust you at a glance, but they do not measure use. Watch installs, new issues from strangers, and returning contributors for a truer picture.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where should I promote my open source project?
&lt;/h3&gt;

&lt;p&gt;Go where your exact users already ask for help. For developer tools, that often means Hacker News, Reddit, relevant forums, and local meetups. Join the conversation first, then share your work where it fits.&lt;/p&gt;

&lt;h3&gt;
  
  
  How fast should I respond to issues and pull requests?
&lt;/h3&gt;

&lt;p&gt;Aim for a first reply within 48 hours. A Mozilla study cited by Open Source Guides found that contributors reviewed within that window came back far more often. A short acknowledgement is enough when you cannot review right away.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I make my open source project show up in Google and AI answers?
&lt;/h3&gt;

&lt;p&gt;Write pages that answer one question each, with the answer in the first two sentences. Keep docs fresh, readable in plain HTML, and easy to link to. Then earn mentions in the communities where developers talk.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do open source maintainers get paid?
&lt;/h3&gt;

&lt;p&gt;Tidelift's 2024 report says income most often comes from donations such as GitHub Sponsors, from employers that include open source work in a salary, and from Tidelift itself. Direct company payments, foundations, and government funding were each a small share.&lt;/p&gt;

</description>
      <category>developers</category>
      <category>github</category>
      <category>opensource</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>What a DX Audit Covers, and 10 Common Problems a DX Audit Can Reveal</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Wed, 04 Nov 2026 13:40:48 +0000</pubDate>
      <link>https://dev.to/studio1hq/what-a-dx-audit-covers-and-10-common-problems-a-dx-audit-can-reveal-3nij</link>
      <guid>https://dev.to/studio1hq/what-a-dx-audit-covers-and-10-common-problems-a-dx-audit-can-reveal-3nij</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Developers who hit a wall with your product rarely tell you. They leave quietly, and a DX audit is how you find that wall before more of them walk into it.&lt;/li&gt;
&lt;li&gt;The first hour matters most. If a new developer cannot get one working result quickly, nothing else you built gets a fair chance.&lt;/li&gt;
&lt;li&gt;Weak docs are the most common cause. More than half of API teams call inconsistent documentation a major problem, and since developers now ask AI tools before opening your docs, unclear pages hurt you twice.&lt;/li&gt;
&lt;li&gt;Most problems are small and cheap to fix: an old quickstart, a vague error message, too many steps to get access, a change nobody announced.&lt;/li&gt;
&lt;li&gt;You can test this yourself in 30 minutes. Sign up like a stranger, follow your own quickstart, and time how long it takes to get a first working result.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Most developers who try your product will never tell you what went wrong. They sign up, hit a wall, and go back to what they were using before. You see a drop in your funnel and nothing else.&lt;/p&gt;

&lt;p&gt;A DX audit is how you find that wall. Someone who has never used your product goes through it the way a new developer would, writes down every point where they got stuck, and turns that list into a plan.&lt;/p&gt;

&lt;p&gt;If you want the bigger picture on why developer products struggle, our post on &lt;a href="https://www.studio1hq.com/blog/common-mistakes-developer-products" rel="noopener noreferrer"&gt;common mistakes startups make when building developer-first products&lt;/a&gt; is a good companion to this one.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a DX Audit?
&lt;/h2&gt;

&lt;p&gt;A DX audit, also called a developer experience audit, is a review of how easy it is for a developer to learn, set up, build with, and get help for your product. It looks at real steps and real time spent, not opinions. The output is a ranked list of problems, with a clear fix for each.&lt;/p&gt;

&lt;p&gt;You can audit an API, an SDK, a CLI tool, a developer platform, an open source project, or the internal tools your own engineers use.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why It Matters: What the Data Says
&lt;/h2&gt;

&lt;p&gt;Developer friction is expensive, and the numbers are bigger than most teams expect.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Time lost every week.&lt;/strong&gt; Atlassian's 2025 State of DevEx report surveyed 3,500 developers in six countries. &lt;a href="https://leaddev.com/velocity/ai-productivity-gains-are-being-offset-by-organizational-bottlenecks" rel="noopener noreferrer"&gt;Half of them said they lose 10 or more hours a week to organizational friction, and 90% lose at least six&lt;/a&gt;. The same report found developers spend only &lt;a href="https://www.atlassian.com/blog/developer/developer-experience-report-2025" rel="noopener noreferrer"&gt;16% of their time writing code&lt;/a&gt;. Atlassian estimates a company with 500 developers could lose up to $7.9 million a year this way.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-serve answers pay off.&lt;/strong&gt; LeadDev reports that developers who can find documentation and knowledge on their own are &lt;a href="https://leaddev.com/velocity/ai-productivity-gains-are-being-offset-by-organizational-bottlenecks" rel="noopener noreferrer"&gt;4.4 times more productive&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Docs are a top complaint.&lt;/strong&gt; In Postman's 2025 State of the API report, &lt;a href="https://nordicapis.com/a-deep-dive-into-the-state-of-the-api-2025/" rel="noopener noreferrer"&gt;more than half of respondents named inconsistent documentation as a major stumbling block&lt;/a&gt;. A year earlier, &lt;a href="https://sdtimes.com/api/report-developers-are-increasingly-adopting-an-api-first-approach/" rel="noopener noreferrer"&gt;39% called it the single biggest roadblock to API work&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintenance eats the week.&lt;/strong&gt; Stripe's Developer Coefficient study found the average developer spends &lt;a href="https://www.oreilly.com/radar/four-short-links-17-september-2018/" rel="noopener noreferrer"&gt;more than 17 hours a week on maintenance, plus about four hours on bad code&lt;/a&gt;. The study is from 2018, but it is still the most quoted number on this topic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AI makes bad docs more visible.&lt;/strong&gt; In the 2025 Stack Overflow Developer Survey, &lt;a href="https://survey.stackoverflow.co/2025/" rel="noopener noreferrer"&gt;84% of respondents use AI tools, and 66% say their biggest frustration is AI answers that are close but not quite right&lt;/a&gt;. When your docs are unclear, those tools get your product wrong too.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Does a DX Audit Cover?
&lt;/h2&gt;

&lt;p&gt;A good audit follows the path a developer takes, from first visit to a working app and then to asking for help. Here are the eight areas we check.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Area&lt;/th&gt;
&lt;th&gt;The question we answer&lt;/th&gt;
&lt;th&gt;What we look at&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;1. The first hour&lt;/td&gt;
&lt;td&gt;How long until a new developer sees something work?&lt;/td&gt;
&lt;td&gt;Landing page, signup, quickstart, time to first API call&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2. Documentation&lt;/td&gt;
&lt;td&gt;Can someone learn the product without asking a person?&lt;/td&gt;
&lt;td&gt;Tutorials, reference pages, concept guides, search, code samples&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;3. API, SDK and CLI design&lt;/td&gt;
&lt;td&gt;Does it behave the way a developer expects?&lt;/td&gt;
&lt;td&gt;Naming, defaults, consistency, language support&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;4. Errors and debugging&lt;/td&gt;
&lt;td&gt;When something breaks, can they fix it alone?&lt;/td&gt;
&lt;td&gt;Error messages, logs, status codes, troubleshooting pages&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;5. Setup and tooling&lt;/td&gt;
&lt;td&gt;Can they run it on their machine without a fight?&lt;/td&gt;
&lt;td&gt;Install steps, dependencies, sandbox, build and test speed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;6. Auth and access&lt;/td&gt;
&lt;td&gt;How many steps stand between signup and a real call?&lt;/td&gt;
&lt;td&gt;API keys, OAuth, approvals, permissions, test data&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7. Support and community&lt;/td&gt;
&lt;td&gt;Does anyone answer, and how fast?&lt;/td&gt;
&lt;td&gt;GitHub issues, Discord or Slack, forum replies, changelogs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;8. AI readability&lt;/td&gt;
&lt;td&gt;Can AI assistants find, read, and cite your docs?&lt;/td&gt;
&lt;td&gt;Page structure, plain text content, llms.txt, answer-style headings&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Most audits also add a ninth thread that runs through all of it: measurement. Without numbers, you cannot tell whether a fix worked.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a DX Audit Works, Step by Step
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Pick the developer.&lt;/strong&gt; Decide who you are auditing for: a beginner trying your API for the first time, or an expert migrating from a competitor. Each one hits different walls.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do a cold run.&lt;/strong&gt; Someone who has never used the product starts from the homepage and tries to build the simplest useful thing. They write down every pause, every guess, and every tab they open to find an answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Read the evidence you already have.&lt;/strong&gt; Support tickets, GitHub issues, community threads, and sales call notes usually repeat the same five complaints.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Talk to a few real developers.&lt;/strong&gt; Five or six short conversations will confirm most of what the cold run found.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check the numbers.&lt;/strong&gt; Look at signup to first successful call, quickstart completion, and how long it takes to find an answer in search. A &lt;a href="https://dev.to/zuplo/how-api-analytics-shapes-developer-experience-3edh"&gt;DEV Community guide on API analytics&lt;/a&gt; lists the onboarding metrics worth tracking, including support ticket volume during onboarding.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Score and rank.&lt;/strong&gt; Every problem gets a rating for how many developers it hits and how badly. The fix list is sorted by that, so the team starts with the biggest win.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  The 10 Problems We Find Most Often
&lt;/h2&gt;

&lt;p&gt;These are patterns we see again and again. Where public research backs one up, we link to it.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The path to a first working result is too long
&lt;/h3&gt;

&lt;p&gt;A developer who signs up wants to see one thing work, fast. Postman calls &lt;a href="https://business.dptribune.com/dptribune/news/read/41565462/the_most_important_api_metric_is_time_to_first_call" rel="noopener noreferrer"&gt;time to first call the most important metric for a public API&lt;/a&gt;. We often find the real number is far longer than the team thinks, because the team has never gone through signup with a fresh account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; a long signup form, a dashboard with no guidance, and docs that explain features before showing a single working call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; one page that takes a new developer from zero to a working response, with a ready-to-run example and a test key that works right away.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The quickstart is out of date
&lt;/h3&gt;

&lt;p&gt;Docs drift. The product changes, the sample code does not, and the first copy-paste throws an error. The 2025 State of Docs report, as summarized by &lt;a href="https://www.digitalapi.ai/blogs/api-documentation-common-mistakes" rel="noopener noreferrer"&gt;DigitalAPI&lt;/a&gt;, found that keeping docs current is the top challenge for over half of documentation teams.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; old package versions, renamed endpoints, screenshots of a dashboard that no longer exists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; run your quickstart in a clean environment on a schedule, and treat a failing quickstart like a failing test.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Docs are written for people who already know the product
&lt;/h3&gt;

&lt;p&gt;Reference pages are easy to write, so that is where most teams stop. New developers need tutorials that walk them through a real task and short explanations of how the system thinks. Postman's 2024 report found that &lt;a href="https://sdtimes.com/api/report-developers-are-increasingly-adopting-an-api-first-approach/" rel="noopener noreferrer"&gt;44% of developers read source code just to understand an API&lt;/a&gt;. That is a sign the docs left something out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; pages full of parameters with no story, and terms used before they are explained.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; cover three layers, which are reference, tutorials, and concept guides. Then hand the docs to someone outside the team and watch where they stall.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Error messages do not tell people what to do
&lt;/h3&gt;

&lt;p&gt;An error that says "Invalid request" sends a developer to a search engine, then to a forum, then to a support chat. Each step costs minutes and goodwill.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; vague messages, error codes with no matching docs page, and failures that give no hint about which field was wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; say what went wrong, why it likely happened, and what to try next. Link each error code to a page that explains it.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Local setup and builds are painful
&lt;/h3&gt;

&lt;p&gt;This one hits open source projects and internal teams hard. If setup takes a full day, people give up or wait for a teammate to help. It also feeds the bigger problem in the Atlassian data above: hours lost to friction that has nothing to do with writing code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; a README with missing steps, unlisted dependencies, "works on my machine" bugs, and tests that take too long to run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; one command to install, one command to run, and a README that a new hire can follow without asking anyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  6. Getting access takes too many steps
&lt;/h3&gt;

&lt;p&gt;Approval queues, sandbox requests, confusing OAuth flows, and keys hidden three menus deep are some of the most common reasons developers drop off before their first call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; a form that needs a human to approve it, auth docs that start with theory, and no test data to try things with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; give instant sandbox access, show the simplest auth method first, and move advanced options to a later page.&lt;/p&gt;

&lt;h3&gt;
  
  
  7. Changes arrive with no warning
&lt;/h3&gt;

&lt;p&gt;Developers build on your product and then you rename a field. If you do not announce it, they find out when their app breaks. A JetBrains survey of plugin developers found that experienced developers want better API documentation notes far more than beginners do, &lt;a href="https://blog.jetbrains.com/platform/2026/03/the-experience-gap-how-developers-priorities-shift-as-they-grow/" rel="noopener noreferrer"&gt;41% versus 17%&lt;/a&gt;. One of the clearest requests was a pointer to the new API whenever an old one is retired.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; no changelog, silent deprecations, and breaking changes tucked inside a minor release.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; keep a public changelog, mark deprecated items in the docs and in code, and always say what replaces them.&lt;/p&gt;

&lt;h3&gt;
  
  
  8. Developers cannot find the answer
&lt;/h3&gt;

&lt;p&gt;Good content is useless if search cannot surface it. Docs hidden behind a login, pages with unclear titles, and search that returns the wrong page all push developers away. Remember the 4.4 times productivity gap for developers who can answer their own questions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; docs that need an account to read, a search box that misses obvious terms, and the same question asked again and again in the community.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; make docs public, name pages after the task a developer is trying to finish, and use your most repeated support questions as a to-do list for new pages.&lt;/p&gt;

&lt;h3&gt;
  
  
  9. Support and community go quiet
&lt;/h3&gt;

&lt;p&gt;Developers read your community channels before they commit. Unanswered questions and old threads say a lot about what life is like as your user.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; a Discord with only announcements, GitHub issues that sit for weeks, and no visible team members.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; set a reply time you can actually meet, answer in public so the next person finds it, and turn good answers into docs. We cover why this matters in &lt;a href="https://www.studio1hq.com/blog/why-developer-communities-matter" rel="noopener noreferrer"&gt;why active developer communities matter for early-stage startups&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  10. AI assistants cannot read or cite your docs
&lt;/h3&gt;

&lt;p&gt;Developers now ask ChatGPT, Claude, Perplexity, and Copilot before they open your docs. Postman's 2025 report says &lt;a href="https://nordicapis.com/a-deep-dive-into-the-state-of-the-api-2025/" rel="noopener noreferrer"&gt;89% of respondents use generative AI tools in their daily work&lt;/a&gt;. If your docs are locked in scripts, buried in PDFs, or written with no clear headings, those tools give wrong answers or skip you entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What it looks like:&lt;/strong&gt; docs that load content with scripts, vague headings, no plain text version, and answers scattered across five pages.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The fix:&lt;/strong&gt; use clear question-style headings, put the direct answer first, keep pages in plain text, and consider adding an llms.txt file. We cover this in depth in &lt;a href="https://www.studio1hq.com/blog/developer-docs-as-aeo-asset" rel="noopener noreferrer"&gt;developer docs as your best AEO asset&lt;/a&gt; and &lt;a href="https://www.studio1hq.com/blog/llms-txt-explained-developer-tools-guide" rel="noopener noreferrer"&gt;llms.txt explained&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  A 30-Minute Mini Audit You Can Run Today
&lt;/h2&gt;

&lt;p&gt;You do not need a full audit to find the worst problems. Try this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a private browser window and find your product from a search, as a stranger would.&lt;/li&gt;
&lt;li&gt;Sign up with a new email address and start a timer.&lt;/li&gt;
&lt;li&gt;Follow your own quickstart exactly as written. Note every error and every place you had to guess.&lt;/li&gt;
&lt;li&gt;Trigger one error on purpose. Is the message clear enough to fix it alone?&lt;/li&gt;
&lt;li&gt;Ask an AI assistant how to do the same task with your product. Check whether the answer is right and whether it cites your docs.&lt;/li&gt;
&lt;li&gt;Write down the time to first working result and the three biggest blockers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the timer ran past what you expected, you have your first fixes. For help tracking results over time, read our post on &lt;a href="https://www.studio1hq.com/blog/developer-tool-content-roi-beyond-pageviews" rel="noopener noreferrer"&gt;measuring developer content ROI beyond pageviews&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a DX audit?
&lt;/h3&gt;

&lt;p&gt;A DX audit is a structured review of how easy your product is for developers to learn, set up, use, and get help with. It follows the real path a developer takes and ends in a ranked list of problems and fixes.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does a developer experience audit include?
&lt;/h3&gt;

&lt;p&gt;It usually includes the first-hour experience, documentation, API or SDK design, error messages, setup and tooling, authentication, support and community, and AI readability. It also sets up the measures you will use to track progress.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who needs a DX audit?
&lt;/h3&gt;

&lt;p&gt;Any team that ships something developers use. That includes API companies, SDK and CLI tool makers, developer platforms, open source projects, and internal platform teams. It helps most when signups are strong, but few developers reach a working integration.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is time to first API call?
&lt;/h3&gt;

&lt;p&gt;It is the time between a developer signing up and making their first successful request. It is one of the clearest signs of how good your onboarding is. Shorter is better, and the gap between what teams assume and what they measure is often large.&lt;/p&gt;

&lt;h3&gt;
  
  
  How is a DX audit different from a UX audit?
&lt;/h3&gt;

&lt;p&gt;A UX audit looks at how end users move through an app. A DX audit looks at how developers move through the tools, docs, and systems they use to build. The questions are different: installation steps, error messages, and example code matter more than button placement.&lt;/p&gt;

&lt;h3&gt;
  
  
  How often should you run one?
&lt;/h3&gt;

&lt;p&gt;Run a full audit before a major launch or after a big product change, and run the 30-minute mini audit every few months. Quickstarts and docs drift quickly, so regular small checks catch problems early.&lt;/p&gt;

</description>
      <category>developers</category>
      <category>documentation</category>
      <category>product</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Build Your Own Grok Bot: A Step-by-Step Guide</title>
      <dc:creator>Nancy Garg</dc:creator>
      <pubDate>Thu, 29 Oct 2026 17:22:47 +0000</pubDate>
      <link>https://dev.to/studio1hq/build-your-own-grok-bot-a-step-by-step-guide-4138</link>
      <guid>https://dev.to/studio1hq/build-your-own-grok-bot-a-step-by-step-guide-4138</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;You can build your own Grok Bot-style team of AI bots with OpenCrewBot, a free, MIT-licensed app that runs on your own machine. You can explore the app without API keys using scripted demo replies. Add a Nebius API key when you’re ready for real model responses.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;What you get:&lt;/strong&gt; a chat app where every contact is a bot with its own model settings, tools, and memory. You can optionally enable a cloud browser through Browserbase. Put several in a room, and they split the work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What you need:&lt;/strong&gt; Node.js 22.13 or newer, pnpm, and five commands. Every API key is optional.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;What it costs:&lt;/strong&gt; the app is free. You pay only for the services you switch on, like open-source models on Nebius Token Factory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;SpaceXAI released Grok Bot as an early beta on August 11, 2026. It gives you named AI teammates that keep working in the cloud, hand tasks to each other, and ask before risky actions. Since October 12, 2026, new users get it through the X Subscription, which starts at $30 a month.&lt;/p&gt;

&lt;p&gt;We liked the idea but wanted something we could run ourselves, on open models, with our data in files we can open. So we built OpenCrewBot and put it on GitHub. This guide walks you through the setup, your first tasks, the API keys, and the problems you might hit along the way.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is OpenCrewBot?
&lt;/h2&gt;

&lt;p&gt;OpenCrewBot is an open-source chat app for your own team of AI bots. It looks like a messaging app. Each contact in the sidebar is a bot with its own name, role, instructions, open-source model, tools, and memory. You can talk to one bot directly, or put a few in a room and let them share the work.&lt;/p&gt;

&lt;p&gt;On first run, you get three bots and one room:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scout&lt;/strong&gt; (Research): searches the web and answers with its sources.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quill&lt;/strong&gt; (Writing): turns notes and research into posts, docs, and emails.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Atlas&lt;/strong&gt; (Planning): breaks goals into steps and hands work to the other two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Studio&lt;/strong&gt; (a room): all three bots together, with Atlas as the lead.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It's built on Mastra, an open-source TypeScript framework for AI agents, and uses open models from Nebius Token Factory. It's a starting point you run yourself, not a hosted product.&lt;/p&gt;

&lt;h3&gt;
  
  
  OpenCrewBot vs Grok Bot at a glance
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Grok Bot&lt;/th&gt;
&lt;th&gt;OpenCrewBot&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Where it runs&lt;/td&gt;
&lt;td&gt;SpaceXAI's cloud&lt;/td&gt;
&lt;td&gt;Your own machine&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Price&lt;/td&gt;
&lt;td&gt;Included in paid plans (from $30/month)&lt;/td&gt;
&lt;td&gt;Free app; you pay only the APIs you switch on&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Models&lt;/td&gt;
&lt;td&gt;Grok&lt;/td&gt;
&lt;td&gt;Open models from Nebius Token Factory's live catalog (MiniMax, DeepSeek, Qwen, GLM, Kimi and more)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Source code&lt;/td&gt;
&lt;td&gt;Closed&lt;/td&gt;
&lt;td&gt;Open, MIT license&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Group chats&lt;/td&gt;
&lt;td&gt;2 to 6 Bots per chat (source)&lt;/td&gt;
&lt;td&gt;Rooms with @mentions, &lt;a class="mentioned-user" href="https://dev.to/everyone"&gt;@everyone&lt;/a&gt; and auto routing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Memory&lt;/td&gt;
&lt;td&gt;Managed by the product&lt;/td&gt;
&lt;td&gt;One plain MEMORY.md file per bot you can open and edit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Browser&lt;/td&gt;
&lt;td&gt;One shared cloud computer for all Bots&lt;/td&gt;
&lt;td&gt;One Browserbase cloud browser per bot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Approvals&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Yes, Allow once or Deny cards in chat&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Apps and MCP&lt;/td&gt;
&lt;td&gt;Connectors, plugins, MCP&lt;/td&gt;
&lt;td&gt;Composio (1,000+ apps) and your own MCP servers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scheduled routines&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Not yet&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multiple users&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No, one local owner&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The short version: Grok Bot is a polished product you rent. OpenCrewBot is a project you own, change, and run on your terms.&lt;/p&gt;

&lt;h2&gt;
  
  
  What do you need before you start?
&lt;/h2&gt;

&lt;p&gt;You need two things on your computer and nothing else to begin:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Node.js 22.13 or newer.&lt;/strong&gt; The project was built on Node 24. Check yours with &lt;code&gt;node -v&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;pnpm&lt;/strong&gt;, the package manager the repo uses. Check it with &lt;code&gt;pnpm -v&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That's it for the first run. API keys come later, and all of them are optional. Here is what each one turns on, so you can decide what you want:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Key&lt;/th&gt;
&lt;th&gt;What it turns on&lt;/th&gt;
&lt;th&gt;Where to get it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;NEBIUS_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Real open-source models. Without it, bots use a scripted mock model.&lt;/td&gt;
&lt;td&gt;Nebius Token Factory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TAVILY_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Web search, page reading and site crawls&lt;/td&gt;
&lt;td&gt;Tavily&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;BROWSERBASE_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;A real cloud browser for bots with the Browser tool&lt;/td&gt;
&lt;td&gt;Browserbase&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;COMPOSIO_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Connected apps like Slack, GitHub, Gmail and Notion&lt;/td&gt;
&lt;td&gt;Composio&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;TYPESAFE_API_KEY&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Jev, which picks the right bot in Auto rooms&lt;/td&gt;
&lt;td&gt;TypeSafe&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If you only add one key, make it Nebius. That's the one that swaps the mock model for real ones.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to build your own Grok Bot with OpenCrewBot, step by step
&lt;/h2&gt;

&lt;p&gt;The whole install is five commands. Open a terminal and run them in order.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Clone the repo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/Studio1-OSS/OpenCrewBot.git
&lt;span class="nb"&gt;cd &lt;/span&gt;OpenCrewBot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: Install the packages
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;install&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Create your settings file
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This copies the example file into a real &lt;code&gt;.env&lt;/code&gt;. Leave it empty for now. Empty means mock mode, which is exactly what you want for a first look.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 4: Start the app
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Open it in your browser
&lt;/h3&gt;

&lt;p&gt;Go to &lt;strong&gt;&lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt;&lt;/strong&gt;. You'll see Scout, Quill, and Atlas in the sidebar, plus the Studio room. Scout and Studio are pinned to the top.&lt;/p&gt;

&lt;p&gt;A small dot on the Settings icon means you're in mock mode. Hover it, and it says the app stays in mock mode until &lt;code&gt;NEBIUS_API_KEY&lt;/code&gt; is set. Nothing is broken. It just means replies come from a scripted model while the tools, approvals, and streaming are all real.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where your data lives
&lt;/h3&gt;

&lt;p&gt;Everything stays in a &lt;code&gt;data&lt;/code&gt; folder inside the project:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;data/opencrewbot.db&lt;/code&gt; holds your bots, rooms, and chats (SQLite).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data/mastra.db&lt;/code&gt; holds each bot's model-side history.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;data/workspaces/&amp;lt;botId&amp;gt;/MEMORY.md&lt;/code&gt; is each bot's memory, as a plain text file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can move the folder anywhere with &lt;code&gt;OPENCREWBOT_DATA_DIR&lt;/code&gt; in &lt;code&gt;.env&lt;/code&gt;. The app sends no telemetry of its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  Your first tasks (no API keys needed)
&lt;/h2&gt;

&lt;p&gt;Mock mode is worth five minutes of your time. The fake model only writes the replies. The memory tool, question cards, approval cards, and streaming are the same code that runs with real models. Open a chat with &lt;strong&gt;Scout&lt;/strong&gt; and try these.&lt;/p&gt;

&lt;h3&gt;
  
  
  Task 1: Make a bot remember something
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;remember that I like short answers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Scout calls its &lt;code&gt;memory_add&lt;/code&gt; tool and writes a dated line to its &lt;code&gt;MEMORY.md&lt;/code&gt; file. Open the bot's &lt;strong&gt;Memory&lt;/strong&gt; tab, and you'll see the line appear. That tab is the file itself, and it refreshes live when the bot writes to it. You can edit it there or in any text editor.&lt;/p&gt;

&lt;p&gt;The first 200 lines of that file load into the bot's instructions on every turn, so it remembers across chats. Anything that looks like a password, token, or API key gets redacted before it's saved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Task 2: Let a bot ask you a question
&lt;/h3&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ask me something
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A question card shows up in the chat with two buttons, &lt;strong&gt;Short&lt;/strong&gt; and &lt;strong&gt;Detailed&lt;/strong&gt;. The bot waits. Click one, and it picks up where it left off. With a real model, a bot uses this when it can't go on without a decision from you.&lt;/p&gt;

&lt;h3&gt;
  
  
  Task 3: See an approval card
&lt;/h3&gt;

&lt;p&gt;None of the starter bots have the browser turned on, so switch it on first:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open a bot's menu in the sidebar and click &lt;strong&gt;Edit profile&lt;/strong&gt;. Its details panel opens.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Edit details&lt;/strong&gt; and turn on &lt;strong&gt;Browser&lt;/strong&gt; under Tools.&lt;/li&gt;
&lt;li&gt;Keep &lt;strong&gt;Approval&lt;/strong&gt; on &lt;strong&gt;Ask first&lt;/strong&gt; and click &lt;strong&gt;Save changes&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;open https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The bot stops and shows a card asking to open the page. &lt;strong&gt;Allow once&lt;/strong&gt; to run it. &lt;strong&gt;Deny&lt;/strong&gt; skips it and the bot carries on. Nothing happens until you choose. (The browser itself needs a Browserbase key, so in mock mode the action will fail after you allow it. The point here is the card.)&lt;/p&gt;

&lt;h3&gt;
  
  
  Task 4: Talk to a room
&lt;/h3&gt;

&lt;p&gt;Open the &lt;strong&gt;Studio&lt;/strong&gt; room. Bots in a room decide who answers in this order:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/everyone"&gt;@everyone&lt;/a&gt;&lt;/strong&gt; (or @all) gets every bot to reply.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/scout"&gt;@scout&lt;/a&gt;&lt;/strong&gt;, &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/quill"&gt;@quill&lt;/a&gt;,&lt;/strong&gt; or &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/atlas"&gt;@atlas&lt;/a&gt;&lt;/strong&gt; gets that bot to reply.&lt;/li&gt;
&lt;li&gt;With no mention, an &lt;strong&gt;Auto&lt;/strong&gt; room asks Jev to pick the best bot. If Jev isn't at least 55% sure, or there's no Jev key, the room's lead answers. In Studio, that's Atlas.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A bot can also @mention a teammate in its reply to hand work off. Atlas is told to send research to Scout and drafting to Quill. Hand-offs stop after two hops, so bots can't keep passing work back and forth forever.&lt;/p&gt;

&lt;p&gt;Two small things you'll notice: messages you send while a bot is busy wait in line until it finishes, and the &lt;strong&gt;Stop&lt;/strong&gt; button cancels a reply midway.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to add API keys (and what each one unlocks)
&lt;/h2&gt;

&lt;p&gt;Once you've seen how it works, open &lt;code&gt;.env&lt;/code&gt; and add keys one at a time. Restart &lt;code&gt;pnpm dev&lt;/code&gt; after every change, because the app only reads the file on start.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Nebius Token Factory: real models
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;NEBIUS_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the big switch. Bots stop using the mock model and start using open-source models from Nebius Token Factory. Each reply then shows its tokens and cost.&lt;/p&gt;

&lt;p&gt;To pick a model, open a bot's details and click &lt;strong&gt;Change&lt;/strong&gt; under Default model. The model sheet suggests three picks and lists every model in the live catalog, with search, context size, tool support, and price. These are the suggestions and prices from the app's built-in list (per million tokens, input/output):&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Pick&lt;/th&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Context&lt;/th&gt;
&lt;th&gt;Price per 1M tokens&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Fastest&lt;/td&gt;
&lt;td&gt;Nemotron 3.5 Lightning&lt;/td&gt;
&lt;td&gt;1M&lt;/td&gt;
&lt;td&gt;$0.06 / $0.24&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best all-rounder (default)&lt;/td&gt;
&lt;td&gt;MiniMax M3&lt;/td&gt;
&lt;td&gt;1M&lt;/td&gt;
&lt;td&gt;$0.30 / $1.20&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Strongest&lt;/td&gt;
&lt;td&gt;Qwen3.5 397B A17B&lt;/td&gt;
&lt;td&gt;262K&lt;/td&gt;
&lt;td&gt;$0.60 / $3.60&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Once your key is set, the live catalog from Nebius replaces these numbers, so check the sheet for current prices. A new model applies from the bot's next reply, with no restart.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Tavily: web search
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;TAVILY_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bots with &lt;strong&gt;Web search&lt;/strong&gt; turned on can now search, read pages, and crawl sites. The sources show up under the answer. Try &lt;code&gt;search for Nebius Token Factory&lt;/code&gt; with Scout.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Browserbase: a real browser
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;BROWSERBASE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bots with &lt;strong&gt;Browser&lt;/strong&gt; turned on get their own cloud browser for pages that need clicks, forms or JavaScript. Open the bot's &lt;strong&gt;Browser&lt;/strong&gt; tab to watch it live, and click in to take over. Two optional settings sit next to it: &lt;code&gt;BROWSERBASE_PROJECT_ID&lt;/code&gt; (worked out from the key if empty) and &lt;code&gt;BROWSERBASE_SESSION_MINUTES&lt;/code&gt; (default 15), which caps how long one session runs. Sessions are released when you reset or delete a bot, so they stop billing.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Composio: your apps
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;COMPOSIO_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Click the plug icon in the sidebar to open &lt;strong&gt;Connections&lt;/strong&gt;. Click &lt;strong&gt;Connect&lt;/strong&gt; on an app, sign in on that app's own page, and come back. Featured apps include Slack, GitHub, Gmail, Google Calendar, Notion, Linear, Google Drive, and Jira, and search finds the rest. Then switch each app on for the bots that should have it, in the bot's details.&lt;/p&gt;

&lt;p&gt;In the same panel, you can add your own remote MCP server by URL and token. There's a preset for GitHub's official server. &lt;strong&gt;Add, and test&lt;/strong&gt; connects right away and tells you how many tools it offers.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. TypeSafe: smart room routing
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;TYPESAFE_API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;your-key-here
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This turns on Jev in Auto rooms. When you post without an @mention, Jev reads the room and picks the best bot in a few hundred milliseconds. Without it, the room's lead always answers.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to make your own bots and rooms
&lt;/h2&gt;

&lt;p&gt;The three starter bots are examples. The real fun starts when you build bots for your own work.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a bot
&lt;/h3&gt;

&lt;p&gt;Click the &lt;strong&gt;+&lt;/strong&gt; at the top of the sidebar and choose &lt;strong&gt;New bot&lt;/strong&gt;. You'll fill in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Name and role:&lt;/strong&gt; up to 40 characters each, like "Scout" and "Research". The name also becomes its @handle in rooms.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Description:&lt;/strong&gt; one line on what the bot does. Write this one carefully. In Auto rooms, Jev reads each bot's description to decide who should answer.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Instructions:&lt;/strong&gt; how the bot should work, up to 8,000 characters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Model:&lt;/strong&gt; any model from the model sheet.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tools:&lt;/strong&gt; Web search, Memory, Code mode, Browser and Ask me questions. Turn on only what the bot needs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Approval:&lt;/strong&gt; &lt;strong&gt;Ask first&lt;/strong&gt; makes browser actions wait for your OK. &lt;strong&gt;Full access&lt;/strong&gt; acts without asking.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Changes apply from the bot's next reply, so you can tweak and test fast.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Code mode does
&lt;/h3&gt;

&lt;p&gt;With Code mode on, the bot can write one small TypeScript function that calls several tools at once, instead of calling them one by one. A question that needs five searches can take one round trip. The code runs in a locked sandbox with no access to your files or the internet, and its only reach is the bot's own tools. Scout has it on by default.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create a room
&lt;/h3&gt;

&lt;p&gt;Click &lt;strong&gt;+&lt;/strong&gt; and choose &lt;strong&gt;New room&lt;/strong&gt;. Give it a name and topic, add members, pick a lead, and choose how it answers:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Mode&lt;/th&gt;
&lt;th&gt;Who answers&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Auto&lt;/td&gt;
&lt;td&gt;Jev picks the best bot (needs a TypeSafe key, otherwise the lead answers)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lead&lt;/td&gt;
&lt;td&gt;The lead bot answers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Everyone&lt;/td&gt;
&lt;td&gt;Every bot answers&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In Auto and Lead rooms, an @mention overrides the mode, so you can send any message to a specific bot. In an Everyone room, every bot replies no matter what.&lt;/p&gt;

&lt;h3&gt;
  
  
  What still asks for permission
&lt;/h3&gt;

&lt;p&gt;Some actions always run on their own: web searches, page reads, memory updates, and lookups in connected apps. Anything that changes something in the real world asks first, unless the bot has Full access. That includes clicking or typing in the browser, sending a Slack message, or opening a GitHub issue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Troubleshooting: common problems and fixes
&lt;/h2&gt;

&lt;p&gt;Most problems come down to a missing key, a missing restart or an old Node version. Here's what you might see and what to do.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;What you see&lt;/th&gt;
&lt;th&gt;Why it happens&lt;/th&gt;
&lt;th&gt;How to fix it&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Every bot replies with "running on the mock model"&lt;/td&gt;
&lt;td&gt;No &lt;code&gt;NEBIUS_API_KEY&lt;/code&gt; is set, or the app wasn't restarted&lt;/td&gt;
&lt;td&gt;Add the key to &lt;code&gt;.env&lt;/code&gt; and restart &lt;code&gt;pnpm dev&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A key you just added does nothing&lt;/td&gt;
&lt;td&gt;The app reads &lt;code&gt;.env&lt;/code&gt; only when it starts&lt;/td&gt;
&lt;td&gt;Stop &lt;code&gt;pnpm dev&lt;/code&gt; and start it again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;The install or start fails right away&lt;/td&gt;
&lt;td&gt;Your Node.js may be older than 22.13, the minimum the project asks for&lt;/td&gt;
&lt;td&gt;Update Node, then run &lt;code&gt;pnpm install&lt;/code&gt; again&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;"Blocked: OpenCrewBot only answers on localhost"&lt;/td&gt;
&lt;td&gt;You opened the app from another device or another host name&lt;/td&gt;
&lt;td&gt;Open it on the same machine at &lt;code&gt;localhost:3000&lt;/code&gt;. To serve another host name on purpose, add it to &lt;code&gt;OPENCREWBOT_ALLOWED_HOSTS&lt;/code&gt; (only behind your own sign-in)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A bot says it can't search right now&lt;/td&gt;
&lt;td&gt;Web search is on, but &lt;code&gt;TAVILY_API_KEY&lt;/code&gt; is missing&lt;/td&gt;
&lt;td&gt;Add the Tavily key and restart&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Browser actions fail after you click Allow once&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;BROWSERBASE_API_KEY&lt;/code&gt; is missing&lt;/td&gt;
&lt;td&gt;Add the Browserbase key and restart&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A bot says connected apps aren't available&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;COMPOSIO_API_KEY&lt;/code&gt; is missing, or the app isn't connected yet&lt;/td&gt;
&lt;td&gt;Add the key, then connect the app in Connections and switch it on for that bot&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;An Auto room always gets the same bot&lt;/td&gt;
&lt;td&gt;No TypeSafe key, or Jev wasn't at least 55% sure&lt;/td&gt;
&lt;td&gt;Add &lt;code&gt;TYPESAFE_API_KEY&lt;/code&gt;, sharpen each bot's description, or @mention the bot you want&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A reply shows "Interrupted by a server restart"&lt;/td&gt;
&lt;td&gt;The server stopped while that bot was replying&lt;/td&gt;
&lt;td&gt;Send the message again. Replies can't resume after a restart&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Clicking an old approval or question card fails&lt;/td&gt;
&lt;td&gt;The bot restarted and that request is no longer waiting&lt;/td&gt;
&lt;td&gt;Ask the bot again to get a fresh card&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Your MCP server won't save&lt;/td&gt;
&lt;td&gt;The URL isn't &lt;code&gt;https://&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Use an https URL. Plain http only works for localhost&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A bot can't take browser screenshots&lt;/td&gt;
&lt;td&gt;Its model can't read images, so the app hides that tool&lt;/td&gt;
&lt;td&gt;Pick a model with vision in the model sheet, or let it read the page as text&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;If something else breaks, the terminal running &lt;code&gt;pnpm dev&lt;/code&gt; prints errors with an &lt;code&gt;[opencrewbot]&lt;/code&gt; tag, which is the first place to look. You can also open an issue on GitHub.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Is there a free, open-source alternative to Grok Bot?
&lt;/h3&gt;

&lt;p&gt;Yes. OpenCrewBot is a free, MIT-licensed app that gives you a team of AI bots with their own models, tools, memory, and browsers. You run it on your own machine and pay only for the services you connect.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I build my own Grok Bot without writing code?
&lt;/h3&gt;

&lt;p&gt;Yes. You need to run five commands in a terminal, and after that, everything happens in the app. Creating bots, rooms, and connections is all done with forms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do I need API keys to try OpenCrewBot?
&lt;/h3&gt;

&lt;p&gt;No. With no keys, it runs in mock mode. A scripted model writes the replies, but memory, question cards, approvals, and streaming all work for real.&lt;/p&gt;

&lt;h3&gt;
  
  
  Which AI models does OpenCrewBot use?
&lt;/h3&gt;

&lt;p&gt;Open-source models from Nebius Token Factory, including MiniMax, DeepSeek, Qwen, GLM, Kimi, Nemotron, and gpt-oss. The default is MiniMax M3. You can give every bot a different model and switch it any time.&lt;/p&gt;

&lt;h3&gt;
  
  
  How much does it cost to run?
&lt;/h3&gt;

&lt;p&gt;The app is free. Model calls are billed by Nebius per token, and every reply shows its own tokens and cost. In the app's built-in list, the default MiniMax M3 costs $0.30 per million input tokens and $1.20 per million output tokens.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is my data private?
&lt;/h3&gt;

&lt;p&gt;Your bots, chats, and memory files stay in a local &lt;code&gt;data&lt;/code&gt; folder, and the app sends no telemetry of its own. Data only leaves your machine for the services you set up. For example, Nebius receives the conversation, and Tavily receives your search queries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can I share it with my team or put it on a server?
&lt;/h3&gt;

&lt;p&gt;Not as it is. It has no sign-in and assumes one owner, so it only listens on your own machine. Adding sign-in and multiple users is on the list of ways to extend it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do the bots remember things?
&lt;/h3&gt;

&lt;p&gt;Each bot has one plain &lt;code&gt;MEMORY.md&lt;/code&gt; file. The bot adds and fixes lines with two tools, and the first 200 lines load into every chat. You can read or edit the file in the app or in any text editor.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can the bots use Slack, GitHub, or Gmail?
&lt;/h3&gt;

&lt;p&gt;Yes, through Composio or your own MCP servers. Lookups run on their own, while actions like sending a message ask for your OK first. Chatting with the bots from inside Slack or Discord isn't there yet.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is OpenCrewBot ready for real work?
&lt;/h3&gt;

&lt;p&gt;It's an early release. On October 13 and 14, 2026, streaming, tools, memory, approvals, rooms, and hand-offs were tested with the mock model. Composio sign-in, live Browserbase sessions, Jev routing, and how well each open model handles tools still need testing with live services.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to try next
&lt;/h2&gt;

&lt;p&gt;You now have your own Grok Bot style team running on your machine. A good next step is to build one bot for a job you do every week, give it a clear description and the fewest tools it needs, and add it to a room with Scout and Quill.&lt;/p&gt;

&lt;p&gt;If you want to take the project further, these are the extensions we've listed in the repo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Let bots hand work to each other in direct chats, not just rooms.&lt;/li&gt;
&lt;li&gt;Add scheduled routines, so a bot can run a task on a timer.&lt;/li&gt;
&lt;li&gt;Let Jev pick the model for each message: a fast one for simple asks, a strong one for hard ones.&lt;/li&gt;
&lt;li&gt;Talk to your bots from Slack or Discord.&lt;/li&gt;
&lt;li&gt;Add sign-in and multiple users before you deploy it anywhere shared.&lt;/li&gt;
&lt;li&gt;Add voice, so you can speak to a bot and hear replies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The code is on GitHub. Issues and pull requests are welcome. Before you open a pull request, run &lt;code&gt;pnpm exec tsc --noEmit&lt;/code&gt; and &lt;code&gt;pnpm lint&lt;/code&gt;, and say whether you tested it with live services or the mock model.&lt;/p&gt;

&lt;p&gt;In the next post, we'll open up the code and explain how we built it: why we used Mastra instead of writing our own agent loop, how rooms decide who answers, and why each bot's memory is a plain Markdown file.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
