<?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: Nakshatra Garg</title>
    <description>The latest articles on DEV Community by Nakshatra Garg (@nakshatra6350).</description>
    <link>https://dev.to/nakshatra6350</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4089704%2F1beeacbf-3289-4ce8-afc2-d86aaa909f6a.jpg</url>
      <title>DEV Community: Nakshatra Garg</title>
      <link>https://dev.to/nakshatra6350</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nakshatra6350"/>
    <language>en</language>
    <item>
      <title>api-diff v0.2.0 — 158 downloads in 3 days, now with array validation and onDrift callback</title>
      <dc:creator>Nakshatra Garg</dc:creator>
      <pubDate>Mon, 24 Aug 2026 13:19:37 +0000</pubDate>
      <link>https://dev.to/nakshatra6350/api-diff-v020-158-downloads-in-3-days-now-with-array-validation-and-ondrift-callback-4j82</link>
      <guid>https://dev.to/nakshatra6350/api-diff-v020-158-downloads-in-3-days-now-with-array-validation-and-ondrift-callback-4j82</guid>
      <description>&lt;p&gt;v0.2.0 of &lt;a class="mentioned-user" href="https://dev.to/nakshatra6350"&gt;@nakshatra6350&lt;/a&gt;/api-diff is live 🚀&lt;/p&gt;

&lt;p&gt;158+ downloads in 3 days since launch.&lt;/p&gt;

&lt;p&gt;Two new features shipped today:&lt;br&gt;
→ Array item validation with exact index in error path&lt;br&gt;
→ onDrift callback — pipe drift events to Sentry, analytics, anywhere&lt;/p&gt;

&lt;p&gt;npm install &lt;a class="mentioned-user" href="https://dev.to/nakshatra6350"&gt;@nakshatra6350&lt;/a&gt;/api-diff&lt;/p&gt;

&lt;p&gt;npm: npmjs.com/package/&lt;a class="mentioned-user" href="https://dev.to/nakshatra6350"&gt;@nakshatra6350&lt;/a&gt;/api-diff&lt;br&gt;
GitHub: github.com/nakshatra6350/api-diff&lt;/p&gt;

</description>
      <category>npm</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>I built an npm package that catches API contract drift before your users do</title>
      <dc:creator>Nakshatra Garg</dc:creator>
      <pubDate>Sat, 22 Aug 2026 12:33:25 +0000</pubDate>
      <link>https://dev.to/nakshatra6350/i-built-an-npm-package-that-catches-api-contract-drift-before-your-users-do-5d55</link>
      <guid>https://dev.to/nakshatra6350/i-built-an-npm-package-that-catches-api-contract-drift-before-your-users-do-5d55</guid>
      <description>&lt;p&gt;You've seen this before.&lt;/p&gt;

&lt;p&gt;Backend quietly renames &lt;code&gt;user_id&lt;/code&gt; to &lt;code&gt;userId&lt;/code&gt;. Or changes &lt;code&gt;amount&lt;/code&gt; from a number to a string. Or drops a field entirely. The TypeScript types go stale. Nobody updates the frontend. And three days later, a user files a bug report about a blank screen.&lt;/p&gt;

&lt;p&gt;This happens in every team, at every scale. I've personally shipped three production bugs in fintech because of it — and in fintech, a broken loan amount field is not a "minor UI glitch."&lt;/p&gt;

&lt;p&gt;So I built something to stop it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Introducing &lt;code&gt;@nakshatra6350/api-diff&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;A zero-config fetch interceptor that watches every API response at runtime and tells you the moment something drifts from what you expected.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; @nakshatra6350/api-diff
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The entire setup is 7 lines
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;init&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;defineSchema&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@nakshatra6350/api-diff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nf"&gt;defineSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;  &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it. Drop this in your app's entry point. Every fetch call to &lt;code&gt;/api/users&lt;/code&gt; is now contract-checked automatically.&lt;/p&gt;

&lt;p&gt;When your backend ships a breaking change, you'll see this in your console immediately:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[api-diff] Contract drift on /api/users:
  • email: expected string, got missing
  • id: expected string, got number
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before your users see anything. Before Sentry fires. Before the support tickets come in.&lt;/p&gt;




&lt;h2&gt;
  
  
  Three modes for three environments
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;    &lt;span class="c1"&gt;// Development  — console.warn, non-blocking&lt;/span&gt;
&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;throw&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c1"&gt;// Tests / CI   — throws an Error, fails the suite&lt;/span&gt;
&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;silent&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// Production   — silent collection, no noise&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In your test suite, flip it to &lt;code&gt;throw&lt;/code&gt; mode and API drift becomes a &lt;strong&gt;failing test&lt;/strong&gt; — it gets caught in CI before it ever reaches production.&lt;/p&gt;




&lt;h2&gt;
  
  
  Nested objects? Handled.
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nf"&gt;defineSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/loans&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;loanId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;number&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;object&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;fields&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;   &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="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 diff engine recurses into nested objects and reports the exact path that drifted — &lt;code&gt;user.name: expected string, got missing&lt;/code&gt; — not just a vague "response mismatch."&lt;/p&gt;




&lt;h2&gt;
  
  
  How it works under the hood
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You call &lt;code&gt;defineSchema()&lt;/code&gt; to register URL → schema pairs in an internal registry&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;init()&lt;/code&gt; wraps &lt;code&gt;globalThis.fetch&lt;/code&gt; with a thin interceptor&lt;/li&gt;
&lt;li&gt;Every fetch call passes through — if the URL matches a schema, the response is &lt;strong&gt;cloned&lt;/strong&gt; (your app gets the original, untouched)&lt;/li&gt;
&lt;li&gt;The clone is parsed and deep-compared field by field, type by type&lt;/li&gt;
&lt;li&gt;Drift is reported based on your chosen mode&lt;/li&gt;
&lt;li&gt;Zero latency added to your actual requests
The interceptor adds no overhead to unmatched requests and only clones responses on matched ones — the clone is a native browser API, not a re-fetch.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Why not just use Zod or OpenAPI validators?
&lt;/h2&gt;

&lt;p&gt;Fair question. Here's how I think about it:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;th&gt;What it's for&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Zod&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Compile-time + runtime validation wired into your data layer. Great, but requires you to own and update the schema actively.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;OpenAPI validators&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Full contract testing with generated specs. Powerful, but heavy — you need backend cooperation and a build step.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;api-diff&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;A lightweight safety net at the fetch layer. No backend changes, no code-gen, no build step. Drop it in, define what you expect, move on.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These tools aren't competitors. I use Zod for domain validation and &lt;code&gt;api-diff&lt;/code&gt; as an early warning system at the network boundary.&lt;/p&gt;




&lt;h2&gt;
  
  
  Full TypeScript support, zero extra packages
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApiSchema&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DiffResult&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DriftItem&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;DiffMode&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@nakshatra6350/api-diff&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Types ship with the package. No &lt;code&gt;@types/&lt;/code&gt; install needed.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's coming in v0.2.0
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Array item validation&lt;/strong&gt; — define a schema for items inside array responses&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;onDrift&lt;/code&gt; callback&lt;/strong&gt; — pipe drift events to Sentry, analytics, or your own endpoint&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  - &lt;strong&gt;Vite plugin&lt;/strong&gt; — define schemas in a config file instead of in code
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;📦 npm → &lt;a href="https://www.npmjs.com/package/@nakshatra6350/api-diff" rel="noopener noreferrer"&gt;npmjs.com/package/@nakshatra6350/api-diff&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;🐙 GitHub → &lt;a href="https://github.com/Nakshatra6350/api-diff" rel="noopener noreferrer"&gt;github.com/nakshatra6350/api-diff&lt;/a&gt;
Built this after 2.5 years of fintech frontend work watching silent API failures slip past TypeScript into production. If you've felt this pain, give it a try and open an issue with feedback — every response shape I haven't thought of yet is a bug I want to know about.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>npm</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
