<?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: Roy Levy</title>
    <description>The latest articles on DEV Community by Roy Levy (@roylevy).</description>
    <link>https://dev.to/roylevy</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%2F4232777%2Fc84c9daf-58a0-42c8-b4e8-47c00e8f37d2.jpeg</url>
      <title>DEV Community: Roy Levy</title>
      <link>https://dev.to/roylevy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/roylevy"/>
    <language>en</language>
    <item>
      <title>Angular vs React in 2026: Which One Survives AI-Written Code?</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Fri, 27 Nov 2026 12:18:13 +0000</pubDate>
      <link>https://dev.to/roylevy/angular-vs-react-in-2026-which-one-survives-ai-written-code-2lk1</link>
      <guid>https://dev.to/roylevy/angular-vs-react-in-2026-which-one-survives-ai-written-code-2lk1</guid>
      <description>&lt;p&gt;&lt;em&gt;I've built with both using Cursor. One writes faster. The other stays clean.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In my last post, &lt;a href="https://medium.com/@roylevy_28840/angular-vs-next-js-in-2026-which-one-actually-makes-you-faster-7f6fe38f1878" rel="noopener noreferrer"&gt;Angular vs Next.js in 2026&lt;/a&gt;, I said the real tradeoff wasn't Angular vs React.&lt;/p&gt;

&lt;p&gt;Some of you didn't love that answer.&lt;/p&gt;

&lt;p&gt;Fair enough. Not everyone needs a full-stack framework. Plenty of teams still spin up a plain React app with Vite, connect it to an API, and ship.&lt;/p&gt;

&lt;p&gt;So let's talk about it.&lt;/p&gt;

&lt;p&gt;But here's the thing. In 2026, I barely write code by hand anymore (my keyboard is mostly for prompts and code review now). Cursor writes. Claude writes. I steer, review, and fix.&lt;/p&gt;

&lt;p&gt;So the question isn't "which one is nicer to write?"&lt;/p&gt;

&lt;p&gt;It's this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which one keeps your app sane when AI is writing most of it?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  AI speaks fluent React
&lt;/h2&gt;

&lt;p&gt;Let's start with the obvious part. AI is really, &lt;em&gt;really&lt;/em&gt; good at React.&lt;/p&gt;

&lt;p&gt;That makes sense. The internet is full of React code. Every model has seen millions of components, hooks, and tutorials. You ask for a feature, and the AI answers fast, confidently, and most of the time it just works.&lt;/p&gt;

&lt;p&gt;I asked Cursor for a dynamic drag-and-drop kanban board using Tailwind and React Query, and of course a "make it look beautiful" ending. The AI spat out three clean components, wired up the state, and it worked flawlessly on the very first try.&lt;/p&gt;

&lt;p&gt;The first few times, it felt like cheating.&lt;/p&gt;

&lt;p&gt;Then a few weeks pass.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxz0yp8mkeplxghgetncz.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxz0yp8mkeplxghgetncz.webp" alt="One AI, five prompts, five different patterns." width="800" height="447"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The wild west, now on autopilot
&lt;/h2&gt;

&lt;p&gt;In my last article I said raw React often feels like the wild west. Five developers, five different systems, one app.&lt;/p&gt;

&lt;p&gt;With AI, you don't need five developers anymore.&lt;/p&gt;

&lt;p&gt;You need one AI and five prompts.&lt;/p&gt;

&lt;p&gt;React gives you a lot of valid ways to do the same thing:&lt;/p&gt;

&lt;p&gt;State? &lt;code&gt;useState&lt;/code&gt;, Context, Zustand, Redux, or the URL.&lt;/p&gt;

&lt;p&gt;Data fetching? &lt;code&gt;useEffect&lt;/code&gt;, React Query, SWR, or "a custom hook I'll clean up later."&lt;/p&gt;

&lt;p&gt;Forms? Controlled, uncontrolled, React Hook Form, Formik.&lt;/p&gt;

&lt;p&gt;Folders? By feature, by type, or by vibes.&lt;/p&gt;

&lt;p&gt;All of them are legit. That's exactly the problem.&lt;/p&gt;

&lt;p&gt;Every prompt, the AI picks &lt;em&gt;one&lt;/em&gt;. Usually whichever fits the snippet it's looking at right now. It has no memory of the decision it made yesterday, and honestly, it doesn't care.&lt;/p&gt;

&lt;p&gt;I once spent an entire afternoon debugging a race condition, only to discover the AI had created four separate custom hooks across three files to fetch the exact same user profile endpoint over and over again.&lt;/p&gt;

&lt;p&gt;Each piece works on its own.&lt;/p&gt;

&lt;p&gt;Together, the app slowly stops making sense.&lt;/p&gt;

&lt;p&gt;One component fetches in a &lt;code&gt;useEffect&lt;/code&gt;. The one next to it uses React Query. A third one has its own little cache that nobody asked for. The state lives in three places and agrees with itself maybe 80% of the time.&lt;/p&gt;

&lt;p&gt;And then you open a file and ask the classic question:&lt;/p&gt;

&lt;p&gt;"Who the hell wrote this?"&lt;/p&gt;

&lt;p&gt;You did. Well, your AI did. Same thing, legally speaking.&lt;/p&gt;

&lt;p&gt;That's not AI-assisted development.&lt;/p&gt;

&lt;p&gt;That's AI-assisted chaos.&lt;/p&gt;

&lt;p&gt;Humans used to need months to create this kind of mess. AI does it over a weekend.&lt;/p&gt;

&lt;h2&gt;
  
  
  Angular keeps the AI on a leash
&lt;/h2&gt;

&lt;p&gt;This is where Angular surprised me again. Just in the opposite direction.&lt;/p&gt;

&lt;p&gt;AI is a little &lt;em&gt;less&lt;/em&gt; fluent in Angular. Sometimes it reaches for older patterns, like NgModules or a wall of RxJS, when a simple signal would do the job. You notice that.&lt;/p&gt;

&lt;p&gt;But when it writes Angular, the result looks like Angular.&lt;/p&gt;

&lt;p&gt;One router.&lt;/p&gt;

&lt;p&gt;One way to do dependency injection.&lt;/p&gt;

&lt;p&gt;One way to define a component.&lt;/p&gt;

&lt;p&gt;A clear home for services.&lt;/p&gt;

&lt;p&gt;A CLI that generates files in the same shape every time.&lt;/p&gt;

&lt;p&gt;The framework itself is a set of rules. The AI just doesn't have much room to get creative. And when it comes to architecture, creative is not a compliment.&lt;/p&gt;

&lt;p&gt;Modern Angular makes it even better. Standalone components killed the NgModule ceremony. Signals made state simple to read. Zoneless is the default since v21. And Angular 22 made Signal Forms stable and OnPush the default change detection.&lt;/p&gt;

&lt;p&gt;That matters for AI more than people think. Less boilerplate means fewer tokens, fewer places to mess up, and smaller diffs for you to review at 11pm.&lt;/p&gt;

&lt;p&gt;Sure, you can write a rules file (&lt;code&gt;.cursorrules&lt;/code&gt;, &lt;code&gt;CLAUDE.md&lt;/code&gt;, whatever your tool uses) in both frameworks. But in Angular, the framework already enforces half the rules before you write a single line of instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where React still wins
&lt;/h2&gt;

&lt;p&gt;This is not an "Angular good, React bad" post. React has real advantages, and some of them get &lt;em&gt;stronger&lt;/em&gt; with AI.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The ecosystem.&lt;/strong&gt; Whatever you need, there's a React library for it, and the AI already knows how to use it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hiring.&lt;/strong&gt; More developers know React. If you're building a team, that's not a small thing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Small apps and prototypes.&lt;/strong&gt; A landing page, an internal tool, an MVP you might throw away next month. Angular's structure can feel like bringing a forklift to move a chair. React gets you from zero to something in minutes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The React Compiler.&lt;/strong&gt; Since React Compiler 1.0, a lot of the manual &lt;code&gt;useMemo&lt;/code&gt; and &lt;code&gt;useCallback&lt;/code&gt; juggling is handled for you. One less thing the AI can get wrong. One less thing you need to review.&lt;/p&gt;

&lt;p&gt;So if day-one speed is what you care about most, React with AI is hard to beat.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to make React work with AI
&lt;/h2&gt;

&lt;p&gt;If you go with React (and a lot of you will), here's what I'd do.&lt;/p&gt;

&lt;p&gt;Decide your stack &lt;em&gt;before&lt;/em&gt; the first prompt:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One router&lt;/li&gt;
&lt;li&gt;One state solution&lt;/li&gt;
&lt;li&gt;One data-fetching library&lt;/li&gt;
&lt;li&gt;One forms library&lt;/li&gt;
&lt;li&gt;One folder structure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Write it down in a rules file. Tell the AI to always follow it. Review every PR for drift.&lt;/p&gt;

&lt;p&gt;Do that, and React plus AI becomes a really strong combo.&lt;/p&gt;

&lt;p&gt;But notice what just happened.&lt;/p&gt;

&lt;p&gt;You just rebuilt, by hand, a chunk of what Angular gives you out of the box.&lt;/p&gt;

&lt;h2&gt;
  
  
  So which one makes you faster?
&lt;/h2&gt;

&lt;p&gt;Here's my honest answer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React is faster on day one.&lt;/strong&gt; The AI writes it fluently, the ecosystem is huge, and you see results right away.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Angular is faster in month six.&lt;/strong&gt; The code still looks like one team wrote it, even when that "team" was mostly an AI. Adding a feature doesn't start with an archaeology dig.&lt;/p&gt;

&lt;p&gt;Last time I called it structured speed vs flexible speed. With AI in the picture, I'd put it like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fast to generate vs safe to maintain.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Final take
&lt;/h2&gt;

&lt;p&gt;A few years ago, Angular vs React was about syntax, bundle size, and learning curves. In 2026, those gaps are way smaller than they used to be.&lt;/p&gt;

&lt;p&gt;The new question is how much freedom you want to give the thing that's writing your code.&lt;/p&gt;

&lt;p&gt;React gives the AI a blank canvas.&lt;/p&gt;

&lt;p&gt;Angular gives it a blueprint.&lt;/p&gt;

&lt;p&gt;So no, I'm still not leaving Angular (at least not entirely). But I totally get why so many people pick React, especially for version one.&lt;/p&gt;

&lt;p&gt;Cheap code is fast to write and expensive to keep. That was true before AI. AI just made the "fast to write" part a lot faster.&lt;/p&gt;

&lt;p&gt;So maybe the simplest way to say it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;React lets AI write more. Angular makes sure it's worth keeping.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Using AI with either framework? I'd love to hear what's working for you, and what's quietly breaking. Drop it in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>angular</category>
      <category>react</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The Code Took Two Days. Everything After That Was the Job.</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Wed, 18 Nov 2026 21:13:21 +0000</pubDate>
      <link>https://dev.to/roylevy/the-code-took-two-days-everything-after-that-was-the-job-2enj</link>
      <guid>https://dev.to/roylevy/the-code-took-two-days-everything-after-that-was-the-job-2enj</guid>
      <description>&lt;p&gt;&lt;em&gt;The code took two days. A real merchant found what it was missing in one.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;On November 2 I made the first commit on a Shopify app for butchers and fish shops. It lets them charge for the actual weight of a cut instead of the estimate. On November 3 the App Store listing was drafted and submitted.&lt;/p&gt;

&lt;p&gt;Two weeks later, a butcher shop found it on the App Store and installed it on a free trial.&lt;/p&gt;

&lt;p&gt;The next afternoon, my app refunded &lt;strong&gt;$20.10&lt;/strong&gt; on one of their orders.&lt;/p&gt;

&lt;p&gt;At that moment, Shopify showed &lt;strong&gt;$20.07 still due&lt;/strong&gt; on the same order.&lt;/p&gt;

&lt;p&gt;The merchant had edited the order after checkout. My app looked at the weights, worked out the difference, and refunded it. It never asked Shopify whether the order already had a balance of its own.&lt;/p&gt;

&lt;p&gt;Here's the uncomfortable part: I still don't know whether $20.10 was the right number.&lt;/p&gt;

&lt;p&gt;If the edit had nothing to do with weight, the refund was fine and the customer still owes the $20.07. If the edit already covered the weights, that $20.10 refund shouldn't have happened at all. Only the merchant knows what the edit changed. My app moved money without knowing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So what was I supposed to have done differently?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not more documentation. I'd read the refund docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  The part AI made cheap
&lt;/h2&gt;

&lt;p&gt;A few years ago, a v1 like this was weeks of work. Read the API docs. Write the boilerplate. Wire up auth, billing and webhooks. Most of a solo build went there.&lt;/p&gt;

&lt;p&gt;That part now takes days. I wrote this app with AI coding agents, and the build stopped being the bottleneck.&lt;/p&gt;

&lt;p&gt;What didn't get cheaper is everything the docs can't tell you.&lt;/p&gt;

&lt;p&gt;Docs tell you what fields an API accepts. They don't tell you that a butcher will edit an order, merge a fulfillment and weigh three cuts before collecting the edit's balance. No amount of reading in advance finds that. A real shop on a busy day does.&lt;/p&gt;

&lt;p&gt;So the job moved. It's less "write the code" and more "run the loops around the code".&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The job now: four loops around a two-day build&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Before code:&lt;/strong&gt; Is anyone feeling this?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;After launch:&lt;/strong&gt; What are they actually doing?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Correctness:&lt;/strong&gt; What does production know that I don't?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory:&lt;/strong&gt; Does the next app start ahead?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Loop 1: Before code, is anyone feeling this?
&lt;/h2&gt;

&lt;p&gt;My app ideas have come from three places. The third one surprised me.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Someone tells you.&lt;/strong&gt; My first marketplace app started with a conversation in late 2025, when AI was just getting good at code. The founder of a well-known Shopify upsell app told me someone at Wix had asked him to build a checkout-links app, and he didn't have the capacity. So I built it. Then I mostly forgot about it for a year, until Wix updated its platform and the app stopped working. I rebuilt it from scratch, and that's when I noticed how fast building had become.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The market tells you.&lt;/strong&gt; I remembered Wix had a page listing the features and apps merchants were asking for. I went back to it and built three apps from that list: address checks for delivery, deposits, and checkout fees. That's the fast kind of research. Read what people already asked for: forums, community threads, feature-request pages, reviews of the apps that already exist. A day or two of reading, then the smallest thing that answers it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your own data tells you.&lt;/strong&gt; Every one of my apps reports to one gateway: installs, setups, usage, orders. So I asked a coding agent to look through that data and suggest a new app. It came back with Package Tiers, an idea I wouldn't have had, and wrote the email to the store that fit it best. That store installed it, reviewed it and my checkout-links app, and paid for a yearly plan right away.&lt;/p&gt;

&lt;p&gt;The weight app was an AI's suggestion too. By then the tools I asked could see everything we'd collected about these marketplaces, their merchants and what they pay for.&lt;/p&gt;

&lt;p&gt;That's when the loops started feeding each other. The data and lessons from the last app became the research for the next one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Talking to people is still the best signal, and the slowest.&lt;/strong&gt; For the weight app, I emailed 25 butchers, fish shops and cheese shops, each time quoting their own product page ("final price based on actual weight"). Most never answered. The kind ones said they already had a solution.&lt;/p&gt;

&lt;p&gt;That told me something too. There was already a paid app for it at $19 a month, with no free plan. The problem was real and people paid to solve it. The gap was a free tier for small shops.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where you launch decides how fast you learn
&lt;/h3&gt;

&lt;p&gt;This is the part I underrated.&lt;/p&gt;

&lt;p&gt;In a marketplace (Shopify, Wix, monday.com), people are already searching for the job your app does. A listing can bring real installs within days.&lt;/p&gt;

&lt;p&gt;None of those 25 emails led to an install. The first real install came from the App Store listing, the day after I sent them.&lt;/p&gt;

&lt;p&gt;That's one launch, so I won't call it a law. But it matches how I see it: a standalone SaaS usually starts with nobody searching for it, and you either wait for SEO or pay for visitors before there's usage to learn from.&lt;/p&gt;

&lt;p&gt;If you want to learn fast, a marketplace is the shortest path I've found.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loop 2: After launch, what are they actually doing?
&lt;/h2&gt;

&lt;p&gt;Shipping isn't the finish line. It's where you start getting data you can't get any other way.&lt;/p&gt;

&lt;p&gt;I also run a few Wix apps. One of them creates shareable checkout links. Seven weeks after a big release, the funnel looked like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Checkout links, real installs since the last big release. The leak was install → first link.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Step&lt;/th&gt;
&lt;th&gt;Stores&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Installed&lt;/td&gt;
&lt;td&gt;22&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Still installed after 2 days&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Made a link&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Got orders through a link&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The obvious plan was more features and some cross-promotion between my apps.&lt;/p&gt;

&lt;p&gt;The data said nobody was reaching the first feature.&lt;/p&gt;

&lt;p&gt;Everyone who made a link did it within about an hour of installing. Stores that stayed but never made a link mostly had big catalogs. My first guess was "service businesses with no products". Wrong. They all had products.&lt;/p&gt;

&lt;p&gt;The funnel told me where to look. It couldn't tell me why.&lt;/p&gt;

&lt;p&gt;So I seeded a test site with a thousand products and tried it. On stores with 37 or more products on Wix's newer catalog, the app couldn't load products at all. 34 worked. 37 failed with "Couldn't load your products".&lt;/p&gt;

&lt;p&gt;No market research would have told me that. No feature would have fixed it. It shipped the same day.&lt;/p&gt;

&lt;p&gt;Pricing works the same way. On another app, one store clicked upgrade on day one and didn't buy. About 22 hours after a 30%-off sale email, they bought the yearly plan. One store proves nothing, but I didn't have to guess where they stopped. I could see it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loop 3: What does production know that I don't?
&lt;/h2&gt;

&lt;p&gt;Back to the $20.10.&lt;/p&gt;

&lt;p&gt;When I rebuilt the order on my test store, Shopify showed me three things I'd never have found in the docs:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A refund for an amount doesn't touch Shopify's balance.&lt;/strong&gt; On my test order, Shopify showed $16.34 due before my weight refund and $16.34 due after it. The status flipped to "Partially refunded", which made the open balance easy to miss.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An edit that raises a quantity repeats that line's tax lines.&lt;/strong&gt; My code added up the rates, so the tax on the weight difference came out doubled. On one test order: $7.07 instead of $6.53. I can't tell you whether that was part of the $20.10. I only know it was wrong.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tax-exempt items can still carry a tax line.&lt;/strong&gt; In some states, exempt groceries come with a rate and a $0 amount. My code saw the rate and added tax to the weight difference. The merchant reported that one on day one.&lt;/p&gt;

&lt;p&gt;The first version of the money logic was roughly this (simplified):&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;// v1: the weights were the whole story&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;difference&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;weighedTotal&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="n"&gt;listedTotal&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;difference&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;await&lt;/span&gt; &lt;span class="nf"&gt;refund&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;difference&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;difference&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="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;sendPaymentLink&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;difference&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's correct in isolation. That's the problem. It treats the weights as the only thing that ever changes an order.&lt;/p&gt;

&lt;p&gt;The fix was to stop deciding money from the weights alone. Now the app asks Shopify for the order's state first and refuses to move money when it's in a state it doesn't fully understand:&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;// Simplified from the real check. Any reason found means no money moves.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;blocker&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;OrderSnapshot&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="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="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;outstanding&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;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;coveredByAuthorization&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sb"&gt;`Shopify shows ${order.outstanding} still due. Collect it first, then weigh.`&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;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;editAddedCustom&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"An edit added a custom item or charge. It may already cover the weight."&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;order&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;amountOnlyRefund&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;"There is already a refund for an amount, not for items."&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;null&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 real version also blocks a balance owed back to the customer, edits Shopify can't explain, cancelled orders and discounted lines.&lt;/p&gt;

&lt;p&gt;Every blocker says what to do next in plain shop language. On my test order, the packer sees "Shopify shows $16.34 still due on this order after an edit. Collect it first with Collect payment on the order, then weigh the items."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When the app doesn't know, it stops and says why.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Six releases in one day
&lt;/h3&gt;

&lt;p&gt;The day the merchant started using it for real looked like this:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One day, six versions. Every release came from something real.&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;What changed&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;v6&lt;/td&gt;
&lt;td&gt;The merchant's day-one reports: tax on exempt items, no weights on payment links, duplicate drafts&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v7&lt;/td&gt;
&lt;td&gt;Outside audit: one claim per order, so two windows can't refund twice&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v8&lt;/td&gt;
&lt;td&gt;Second-model review: recheck every line right before money moves&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v9&lt;/td&gt;
&lt;td&gt;After the $20.10: block edited or unsettled orders&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v10&lt;/td&gt;
&lt;td&gt;Weigh settled edits again, fix the doubled tax, 3 gaps from review&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;v11&lt;/td&gt;
&lt;td&gt;Log every weighing and every block with its reason&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two habits made that pace safe enough.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One model writes, another hunts.&lt;/strong&gt; The v9 guard was written by one coding model and reviewed by another. The v10 rework went the other way, and the reviewer found three gaps I'd missed: a refund someone had already made by hand, an edited order with no edit history, and an edited order covered only by a card authorization. Each one could have moved the wrong amount.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The test drives the real admin.&lt;/strong&gt; I can't click through ten scenarios by hand every release, across several apps. So a Playwright suite opens the real order page on a test store, runs the weighing screen, and checks Shopify's books afterwards. The v10 release passed 71 unit tests and 9 of 9 of those end-to-end scenarios, then passed again against the live release itself.&lt;/p&gt;

&lt;h3&gt;
  
  
  Safe, and still wrong
&lt;/h3&gt;

&lt;p&gt;Look at v9 again.&lt;/p&gt;

&lt;p&gt;After the $20.10, I pushed a quick guard that blocked every edited order. No more wrong refunds. Also no more weighing for this merchant, because this merchant edits orders. Every one of them went back to being worked out by hand in Shopify, which is the exact job they'd installed the app to stop doing.&lt;/p&gt;

&lt;p&gt;They uninstalled.&lt;/p&gt;

&lt;p&gt;My email to them started with "I saw you uninstalled, and I don't blame you."&lt;/p&gt;

&lt;p&gt;The money was safe. The customer was gone.&lt;/p&gt;

&lt;p&gt;Failing closed was right. Failing closed on &lt;em&gt;everything&lt;/em&gt; was just a different bug. A blocker that's too broad never moves the wrong money. It quietly stops the app from doing its job, and the merchant does the work by hand until they decide they don't need you.&lt;/p&gt;

&lt;p&gt;v10 narrowed it. Settled edits are weighed again, and only the cases I genuinely can't verify are blocked. v11 logs every weighing and every block with its reason, numbers only, no customer data. Next time a blocker fires too often, I want to see it in the logs before a merchant feels it in their workday.&lt;/p&gt;

&lt;p&gt;That's the loop. Ship lean, block only what you can't verify, log every block, and harden the paths real users hit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loop 4: The next app starts ahead
&lt;/h2&gt;

&lt;p&gt;Every trap goes into a skill file that my coding agents read before they touch these apps. This is from the real one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="gu"&gt;## Money-moving patterns (both apps follow these; keep them)
&lt;/span&gt;
&lt;span class="k"&gt;- &lt;/span&gt;Tax: an order edit that raises a quantity &lt;span class="gs"&gt;**repeats the line's tax lines**&lt;/span&gt;
  for the added units. Count each tax once by title + rate, or the tax on
  the difference doubles.
&lt;span class="k"&gt;- &lt;/span&gt;&lt;span class="gs"&gt;**Never pick refund vs. charge from the weight math alone.**&lt;/span&gt; Weighwise
  blocks while totalOutstandingSet isn't zero (an authorization covering it
  exactly is fine): the merchant settles the balance on the order first.
&lt;span class="k"&gt;- &lt;/span&gt;A weight refund (custom amount, no items) leaves totalOutstandingSet
  unchanged and flips the status to Partially refunded, which hides a
  balance still due.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file has one rule about itself: when you learn a durable trap, add it here. A trap saved only in a dated note gets rediscovered the hard way.&lt;/p&gt;

&lt;p&gt;My second Shopify app already follows those money rules. It didn't have to learn them from a customer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this approach falls short
&lt;/h2&gt;

&lt;p&gt;I don't want to oversell this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I shipped money logic that didn't fail closed, then failed closed too hard.&lt;/strong&gt; "Ship fast and learn" is fine for a settings page. For anything that refunds or charges, the first version should already refuse the states it doesn't understand, and only those. I learned both halves from one merchant, and lost the merchant. You don't have to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The numbers are small.&lt;/strong&gt; 22 installs and one upgrade are readings, not statistics. They tell me where to look, not how big the effect is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Marketplaces own your distribution.&lt;/strong&gt; They bring you buyers fast, and they also set the rules: review queues, ranking, required security settings, what your app is allowed to touch. Build there with your eyes open.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some products shouldn't skip the slow loop.&lt;/strong&gt; Regulated work, or B2B with a long sales cycle, needs real conversations before you build. Forum-mining a weekend won't cover it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd do this week
&lt;/h2&gt;

&lt;p&gt;If you're a solo builder shipping with AI:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Before you build, spend a day reading what people already complain about: product pages, forums, reviews of the existing apps.&lt;/li&gt;
&lt;li&gt;Log the first-run funnel from day one: install, setup, first real use.&lt;/li&gt;
&lt;li&gt;For anything that moves money, block only the states you can't verify, say what to do next, and log every block so you see when one fires too often.&lt;/li&gt;
&lt;li&gt;Rebuild your worst real incident on a test store and make it an end-to-end test.&lt;/li&gt;
&lt;li&gt;Write every platform trap into a file your agents read before they start.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  So what is the job now?
&lt;/h2&gt;

&lt;p&gt;Here's my honest answer.&lt;/p&gt;

&lt;p&gt;The code got cheap. Being wrong in production didn't.&lt;/p&gt;

&lt;p&gt;A solo engineer used to be paid to turn a spec into working software. Now the software shows up fast, and the work is everything around it: finding out who needs it, watching what they do, catching what the docs never said, and making sure each lesson sticks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You're not paid to type anymore. You're paid to close the loops.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you shipped something fast with AI and it now carries real users or real money, this is the work I do when I &lt;a href="https://roylevy.dev/ai-prototype-to-production" rel="noopener noreferrer"&gt;take an AI prototype to production&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://roylevy.dev/blog/solo-engineer-job-after-ai" rel="noopener noreferrer"&gt;roylevy.dev&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Building alone with AI agents? I'd love to hear which loop is costing you the most right now. &lt;a href="https://roylevy.dev/contact" rel="noopener noreferrer"&gt;Send me a note&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>shopify</category>
      <category>startup</category>
    </item>
    <item>
      <title>How to Add a Blog to Your Next.js Site with MDX (and Keep It Alive)</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Sun, 15 Nov 2026 10:05:30 +0000</pubDate>
      <link>https://dev.to/roylevy/how-to-add-a-blog-to-your-nextjs-site-with-mdx-and-keep-it-alive-4hdk</link>
      <guid>https://dev.to/roylevy/how-to-add-a-blog-to-your-nextjs-site-with-mdx-and-keep-it-alive-4hdk</guid>
      <description>&lt;p&gt;Adding a blog to a Next.js site takes an afternoon.&lt;/p&gt;

&lt;p&gt;Keeping it alive takes a habit.&lt;/p&gt;

&lt;p&gt;This guide covers both. First, a small, boring setup that will not need a rewrite in six months: posts as MDX files in your repo, static pages, proper metadata, and a sitemap. Then, what actually stops most product blogs at four posts, and how to get past it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Tested on:&lt;/strong&gt; Next.js 16.4 (App Router), React 19.2, next-mdx-remote 6.0, gray-matter 4.0, remark-gfm 4.0, in November 2026. I built a fresh app with exactly the code below, ran &lt;code&gt;next build&lt;/code&gt;, and checked the output. If you are on another version, check the &lt;a href="https://nextjs.org/docs/app/guides/mdx" rel="noopener noreferrer"&gt;Next.js MDX guide&lt;/a&gt; for changes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Pick the setup first
&lt;/h2&gt;

&lt;p&gt;Next.js has two common ways to do MDX.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;@next/mdx&lt;/code&gt;&lt;/strong&gt; turns &lt;code&gt;.mdx&lt;/code&gt; files into pages or importable components. It is the official route and works well. It does not read YAML frontmatter out of the box, so titles and dates usually go in an exported &lt;code&gt;metadata&lt;/code&gt; object, or you add remark plugins for frontmatter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;next-mdx-remote&lt;/code&gt; + &lt;code&gt;gray-matter&lt;/code&gt;&lt;/strong&gt; treats each post as a plain file with YAML frontmatter at the top. You read the file, split the frontmatter from the body, and render the body as MDX on the server.&lt;/p&gt;

&lt;p&gt;This guide uses the second one, for a practical reason: YAML frontmatter is what most editors, CMS exports, and AI writing tools produce. Your posts stay portable files that any tool can read and write.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Install
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm install next-mdx-remote gray-matter remark-gfm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;remark-gfm&lt;/code&gt; adds GitHub-style tables, task lists, and strikethrough. Skip it if you don't need them.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Write your first post
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;content/blog/hello-world.mdx&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;---
title: "Hello, world"
description: "The first post on our new blog."
date: "2026-11-15"
---

This is the first post. It is plain **Markdown**, with one custom component:

&amp;lt;Callout&amp;gt;Components work too, as long as you pass them in.&amp;lt;/Callout&amp;gt;

| Feature | Works |
| --- | --- |
| Tables | Yes, with remark-gfm |
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The file name is the URL slug. This one becomes &lt;code&gt;/blog/hello-world&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Quote your dates.&lt;/strong&gt; In YAML, an unquoted &lt;code&gt;date: 2026-11-15&lt;/code&gt; is parsed as a JavaScript &lt;code&gt;Date&lt;/code&gt;, not a string. Sorting by string and passing it to the sitemap then break in confusing ways. I hit this while testing. Write &lt;code&gt;date: "2026-11-15"&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  3. Read the posts
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;lib/posts.ts&lt;/code&gt;. It lists the files, splits frontmatter from content, and returns posts newest first.&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;import&lt;/span&gt; &lt;span class="n"&gt;fs&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:fs"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"node:path"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;matter&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"gray-matter"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;POSTS_DIR&lt;/span&gt; &lt;span class="o"&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;join&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="nf"&gt;cwd&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;"content/blog"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;PostMeta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;slug&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;title&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;description&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;date&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="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;readPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&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="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readFileSync&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;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;POSTS_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`${slug}.mdx`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"utf8"&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;data&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="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;matter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;raw&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;meta&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PostMeta&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;slug&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="nb"&gt;String&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;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&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;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="s2"&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;date&lt;/span&gt;&lt;span class="p"&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;data&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="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="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="n"&gt;content&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getAllPosts&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;PostMeta&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;fs&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;readdirSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;POSTS_DIR&lt;/span&gt;&lt;span class="p"&gt;)&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;file&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;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;endsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;".mdx"&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;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;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;readPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&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;mdx&lt;/span&gt;$&lt;span class="o"&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="p"&gt;)&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="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;b&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="nf"&gt;localeCompare&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;date&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&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="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;fs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;existsSync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;POSTS_DIR&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`${slug}.mdx`&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;readPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs only on the server, at build time, so using &lt;code&gt;fs&lt;/code&gt; is fine.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Add your components
&lt;/h2&gt;

&lt;p&gt;MDX can render React components, but only the ones you pass in. Create &lt;code&gt;components/mdx.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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;Callout&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;:&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="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ReactNode&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;aside&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="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;borderLeft&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"4px solid #e8a33d"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"0.75rem 1rem"&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="n"&gt;children&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;aside&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="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;mdxComponents&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Callout&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;Keep this list short and stable. Every component you add here is one more thing every future post, and every tool that writes posts for you, has to get exactly right, or the build fails.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Set a base URL
&lt;/h2&gt;

&lt;p&gt;Canonical and Open Graph URLs need an absolute base. In &lt;code&gt;app/layout.tsx&lt;/code&gt;, add &lt;code&gt;metadataBase&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="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="nc"&gt;Metadata&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Metadata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;metadataBase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"https://example.com"&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;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;RootLayout&lt;/span&gt;&lt;span class="p"&gt;(&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="p"&gt;:&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="nc"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;ReactNode&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="n"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"en"&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;body&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;children&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;body&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;html&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;Use your real domain. Relative URLs like &lt;code&gt;/blog/hello-world&lt;/code&gt; in metadata are resolved against it.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. The blog index
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;app/blog/page.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="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="nc"&gt;Metadata&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Link&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next/link"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;getAllPosts&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@/lib/posts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;metadata&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Metadata&lt;/span&gt; &lt;span class="o"&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="s2"&gt;"Blog"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Notes from the team."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;alternates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;canonical&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"/blog"&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;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;BlogIndex&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;posts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getAllPosts&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;main&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;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nc"&gt;Blog&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;h1&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;ul&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;posts&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;post&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="n"&gt;li&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;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&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;Link&lt;/span&gt; &lt;span class="n"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sb"&gt;`/blog/${post.slug}`&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;post&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="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nc"&gt;Link&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;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;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;description&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;p&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;li&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;ul&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;main&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;h2&gt;
  
  
  7. The post page
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;app/blog/[slug]/page.tsx&lt;/code&gt;. This is where most of the work happens:&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;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;Metadata&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;notFound&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next/navigation"&lt;/span&gt;&lt;span class="p"&gt;;&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;MDXRemote&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next-mdx-remote/rsc"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;remarkGfm&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"remark-gfm"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;mdxComponents&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@/components/mdx"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;getAllPosts&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;getPost&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@/lib/posts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;Props&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;slug&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="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="c1"&gt;// Only the posts that exist at build time; anything else is a 404.&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;dynamicParams&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;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;generateStaticParams&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;getAllPosts&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;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;post&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="n"&gt;slug&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;generateMetadata&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Props&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Metadata&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;slug&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;params&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;post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&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;post&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="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;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;alternates&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;canonical&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`/blog/${slug}`&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;openGraph&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"article"&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;post&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="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`/blog/${slug}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;publishedTime&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;date&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;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nc"&gt;PostPage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;params&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Props&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;slug&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;params&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;post&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getPost&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;slug&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;post&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nf"&gt;notFound&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;jsonLd&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="s2"&gt;"@context"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://schema.org"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="s2"&gt;"@type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"BlogPosting"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;headline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;datePublished&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="n"&gt;date&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="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;main&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;article&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;h1&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;post&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="n"&gt;title&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;h1&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;time&lt;/span&gt; &lt;span class="n"&gt;dateTime&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;post&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="n"&gt;date&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;post&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="n"&gt;date&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;time&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;MDXRemote&lt;/span&gt;
          &lt;span class="n"&gt;source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;post&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;components&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;mdxComponents&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
          &lt;span class="n"&gt;options&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;mdxOptions&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;remarkPlugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;remarkGfm&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;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;article&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;script&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;"application/ld+json"&lt;/span&gt;
        &lt;span class="n"&gt;dangerouslySetInnerHTML&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;__html&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="n"&gt;jsonLd&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&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;g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"\\u003c"&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;gt;&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="n"&gt;main&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;What each piece does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;params&lt;/code&gt; is a Promise&lt;/strong&gt; in current Next.js, so you &lt;code&gt;await&lt;/code&gt; it in both the page and &lt;code&gt;generateMetadata&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;generateStaticParams&lt;/code&gt;&lt;/strong&gt; lists every post, so each one is prerendered as static HTML at build time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;dynamicParams = false&lt;/code&gt;&lt;/strong&gt; turns any slug that isn't a file into a 404, instead of trying to render it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;generateMetadata&lt;/code&gt;&lt;/strong&gt; gives each post its own title, description, canonical URL, and Open Graph tags.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The JSON-LD script&lt;/strong&gt; tells search engines this page is a blog post. The &lt;code&gt;.replace&lt;/code&gt; stops a &lt;code&gt;&amp;lt;&lt;/code&gt; in your text from breaking out of the script tag.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Add a sitemap
&lt;/h2&gt;

&lt;p&gt;Create &lt;code&gt;app/sitemap.ts&lt;/code&gt; so search engines find new posts without waiting for a link:&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;import&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nc"&gt;MetadataRoute&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"next"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;getAllPosts&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s2"&gt;"@/lib/posts"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="no"&gt;SITE_URL&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"https://example.com"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sitemap&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;MetadataRoute&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Sitemap&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`${SITE_URL}/blog`&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;getAllPosts&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;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;post&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="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`${SITE_URL}/blog/${post.slug}`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="n"&gt;lastModified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;post&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="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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If your site already has a sitemap, add the post entries to it instead of creating a second one.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Build and check
&lt;/h2&gt;

&lt;p&gt;Run &lt;code&gt;next build&lt;/code&gt;. You should see your post listed as prerendered:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Route (app)
├ ○ /blog
├   /blog/[slug]
│ └ ● /blog/hello-world
└ ○ /sitemap.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run &lt;code&gt;next start&lt;/code&gt; and check four things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;/blog/hello-world shows the post, the Callout, and the table.&lt;/li&gt;
&lt;li&gt;View source shows a canonical link and og:url using your real domain.&lt;/li&gt;
&lt;li&gt;/sitemap.xml lists the blog and every post.&lt;/li&gt;
&lt;li&gt;/blog/anything-else returns 404.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That is the whole blog. Styling is up to you: the &lt;a href="https://github.com/tailwindlabs/tailwindcss-typography" rel="noopener noreferrer"&gt;Tailwind typography plugin&lt;/a&gt; is a quick way to make the article body readable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where product blogs actually die
&lt;/h2&gt;

&lt;p&gt;The setup above takes an afternoon. Most product blogs still stop at four posts.&lt;/p&gt;

&lt;p&gt;It is rarely the code. It is that every post competes with shipping the product, and the product always wins. The drafts folder fills up. The last post is from March.&lt;/p&gt;

&lt;p&gt;A few things make it more likely you keep going:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Write for searches people actually make.&lt;/strong&gt; Pick each topic from a real query, either one you already show up for in Search Console, or one autocomplete suggests. A post nobody searches for is hard to justify writing next month.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Keep the publishing path short.&lt;/strong&gt; Write the post in a branch, open a pull request, read the preview deploy, merge. No CMS, no copy-paste.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Update before you add.&lt;/strong&gt; Once you have a dozen posts, the best next move is often fixing one that is slipping. My guide to &lt;a href="https://nichepressa.com/blog/content-decay-search-console" rel="noopener noreferrer"&gt;finding and fixing content decay&lt;/a&gt; shows how to spot them.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Get help with the writing, not the judgment.&lt;/strong&gt; An AI tool can draft. You still decide what is true and what you would actually recommend.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want that help to land in this exact setup, as MDX files with frontmatter committed to your repo, that is what I build NichePressa for: it writes in your voice, plans topics from your Search Console data, and commits to a branch you merge. For the wider field, see my comparison of &lt;a href="https://nichepressa.com/blog/best-ai-seo-tools-for-saas-founders" rel="noopener noreferrer"&gt;AI SEO tools for SaaS founders&lt;/a&gt;.&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Should I use &lt;a class="mentioned-user" href="https://dev.to/next"&gt;@next&lt;/a&gt;/mdx or next-mdx-remote for a Next.js blog?
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;@next/mdx&lt;/code&gt; if you are happy writing each post as a page or importable component and keeping metadata in an exported object. Use &lt;code&gt;next-mdx-remote&lt;/code&gt; with &lt;code&gt;gray-matter&lt;/code&gt; if you want posts as files with YAML frontmatter, which is what most editors and writing tools produce.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I add frontmatter to MDX in Next.js?
&lt;/h3&gt;

&lt;p&gt;Put YAML between &lt;code&gt;---&lt;/code&gt; lines at the top of each file, then read it with &lt;code&gt;gray-matter&lt;/code&gt;, which returns the frontmatter as &lt;code&gt;data&lt;/code&gt; and the body as &lt;code&gt;content&lt;/code&gt;. &lt;code&gt;@next/mdx&lt;/code&gt; does not read frontmatter by default. Its docs suggest &lt;code&gt;export const metadata&lt;/code&gt; or a remark plugin instead.&lt;/p&gt;

&lt;h3&gt;
  
  
  Will an MDX blog be static in the App Router?
&lt;/h3&gt;

&lt;p&gt;Yes, if you list every slug in &lt;code&gt;generateStaticParams&lt;/code&gt; and read files at build time. &lt;code&gt;next build&lt;/code&gt; will mark each post as prerendered. Set &lt;code&gt;dynamicParams = false&lt;/code&gt; so unknown slugs return 404.&lt;/p&gt;

&lt;h3&gt;
  
  
  How do I add a sitemap for blog posts in Next.js?
&lt;/h3&gt;

&lt;p&gt;Create &lt;code&gt;app/sitemap.ts&lt;/code&gt; that returns an array of URLs, including one entry per post from the same function that lists your posts. Next.js serves it at &lt;code&gt;/sitemap.xml&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why does my frontmatter date sort wrong?
&lt;/h3&gt;

&lt;p&gt;An unquoted YAML date such as &lt;code&gt;date: 2026-11-15&lt;/code&gt; is parsed into a JavaScript &lt;code&gt;Date&lt;/code&gt; object, not a string. Quote it, &lt;code&gt;date: "2026-11-15"&lt;/code&gt;, or convert it explicitly when you read the post.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'd love to hear how your blog setup is working, and what quietly broke. Drop it in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
      <category>webdev</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>My LLM Pipeline Never Crashed. It Just Quietly Got Worse.</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Thu, 12 Nov 2026 17:21:04 +0000</pubDate>
      <link>https://dev.to/roylevy/my-llm-pipeline-never-crashed-it-just-quietly-got-worse-2jn2</link>
      <guid>https://dev.to/roylevy/my-llm-pipeline-never-crashed-it-just-quietly-got-worse-2jn2</guid>
      <description>&lt;p&gt;&lt;em&gt;Normal software fails loudly. My article pipeline failed with HTTP 200 and valid JSON.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When a normal app breaks, it tells you.&lt;/p&gt;

&lt;p&gt;A webhook is missing a field. A database constraint trips. An exception bubbles up, and the stack trace points at the exact line.&lt;/p&gt;

&lt;p&gt;Annoying? Sure. But at least you know.&lt;/p&gt;

&lt;p&gt;I've been building a pipeline that writes blog articles for real sites. A planner writes a brief, a writer drafts the article, an editor revises it. Each stage hands the next one its instructions.&lt;/p&gt;

&lt;p&gt;This week I found this inside one of those briefs, in a section plan for an article about one of my own case studies:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Use note b51d42cf-cf42-4c28-ae&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That's it. That's where the instruction ends.&lt;/p&gt;

&lt;p&gt;Half a UUID. No error. No alert. Every check passed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So how do you debug a bug that looks exactly like success?&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Half a UUID, zero errors
&lt;/h2&gt;

&lt;p&gt;Here's what happened.&lt;/p&gt;

&lt;p&gt;The planner returns its brief as structured JSON. To keep briefs tight, the schema had length limits: 280 characters per outline point, 240 per note for the writer, 155 for the meta description, 1,600 for the brief itself.&lt;/p&gt;

&lt;p&gt;Reasonable, right? Here's roughly what we sent the model (simplified):&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="n"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"array"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;maxLength&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;280&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;With OpenAI's strict structured outputs, the model doesn't fail when it hits a &lt;code&gt;maxLength&lt;/code&gt;. In our runs, it just stopped the string. Mid-sentence. Sometimes mid-word.&lt;/p&gt;

&lt;p&gt;Here's the outline point from the hook, exactly as the planner returned it (wrapped here so you can read it). It's 280 characters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## Sniffo.ai separates collected inputs from
scoring decisions (220 words): Use note
4e7d7a7c-1c6e-422b-b865-4953727d9931 to
explain SourceItem rows, the separate
Opportunity mapper, business-profile
application, and re-scoring without network
work. Use note b51d42cf-cf42-4c28-ae
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few more from the same two weeks:&lt;/p&gt;

&lt;p&gt;"…a product can assess separatel"&lt;/p&gt;

&lt;p&gt;"…or validate the planned duration through a complete"&lt;/p&gt;

&lt;p&gt;The response was valid JSON. Our Zod schema checked the length, and the length was fine (it was &lt;em&gt;exactly&lt;/em&gt; the limit). So the repair step we had for bad briefs never ran.&lt;/p&gt;

&lt;p&gt;Then the writer got its instructions with the ending missing. And the ending is usually the important part: which note to use, what the section should prove, how it should land.&lt;/p&gt;

&lt;p&gt;The writer doesn't complain either. It works with whatever it got.&lt;/p&gt;

&lt;p&gt;So I counted. Two weeks of briefs, 14 of them, across 6 sites:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;23 of 120 writer notes stopped at exactly 240 characters.&lt;/li&gt;
&lt;li&gt;7 of 96 outline points stopped at exactly 280.&lt;/li&gt;
&lt;li&gt;11 of the 14 briefs had at least one field cut off.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Eleven out of fourteen.&lt;/p&gt;

&lt;p&gt;Nothing crashed. Not once.&lt;/p&gt;

&lt;h2&gt;
  
  
  The guards were the bugs
&lt;/h2&gt;

&lt;p&gt;Once I started looking for this shape, I kept finding it. Same week, same pipeline:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The link check removed every internal link.&lt;/strong&gt; After a prompt update, the planner started writing links as bare slugs (&lt;code&gt;/some-post&lt;/code&gt;) instead of real paths (&lt;code&gt;/blog/some-post&lt;/code&gt;). The link check couldn't match them, so it did its job and unlinked them. All of them. Every target page actually existed. The drafts came out with orphan sentences like "read Anno 1800 vs Farthest Frontier." pointing at nothing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A capital letter threw away a whole edit.&lt;/strong&gt; The editor capitalized a link's anchor text. The check that makes sure the editor didn't break links compared links by their text, saw a "changed" link, and discarded the entire editorial pass. The article kept its unedited draft.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thai text blew the token budget.&lt;/strong&gt; The budget assumed English-like characters per token. A Thai draft of 12.4k characters is about 11k tokens, against a 9k budget. The editor's reply came back as invalid JSON, so the edit was skipped. Silently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A word count halved the articles.&lt;/strong&gt; The new prompts asked for a target word count in each brief. New drafts came in at 722–1,133 words. The old ones ran 1,128–2,193. The worked examples, the most useful part, were what got cut. No error. Just thinner articles. They lost a side-by-side comparison against the old prompts, 4–1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1et78vf8k2hmwjqv1zet.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1et78vf8k2hmwjqv1zet.webp" alt="Four guards, four green checks, four things quietly deleted." width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Look at those again.&lt;/p&gt;

&lt;p&gt;Every one of them is a safety check doing exactly what it was built to do. Too long? Cut it. Link doesn't match? Remove it. Edit looks wrong? Throw it away.&lt;/p&gt;

&lt;p&gt;Each guard was built to keep the pipeline running.&lt;/p&gt;

&lt;p&gt;So when something went wrong, it didn't stop. It deleted something and kept going.&lt;/p&gt;

&lt;p&gt;That's not graceful degradation.&lt;/p&gt;

&lt;p&gt;That's silent data loss with good manners.&lt;/p&gt;

&lt;h2&gt;
  
  
  More rules made it worse
&lt;/h2&gt;

&lt;p&gt;The obvious move when an AI gets something wrong is to add a rule.&lt;/p&gt;

&lt;p&gt;I tried that. It backfired twice.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;First try:&lt;/strong&gt; the platform prompts were full of "never claim X" and "don't add Y" lines. Those lists planted the exact words they were warning against. My own site's first generated article put a disclaimer on &lt;em&gt;my own&lt;/em&gt; 30% result, because the prompts were full of warnings about numbers. Rewriting every rule as "do this" instead of "never do that" took the avoid-lines from 46–86 per site down to 0–3.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Second try:&lt;/strong&gt; some articles had worked examples with numbers that went past real limits. So I added a "real limits" rule to the writer, the planner and the prompt generators. The planner turned it into "numerical examples must be supported by item data." One article dropped its example numbers completely. Others started hedging ("explicitly illustrative"). It lost the blind test to the version without the rule, 3–2.&lt;/p&gt;

&lt;p&gt;Same lesson both times.&lt;/p&gt;

&lt;p&gt;Tell the writer to be careful, and it gets vague.&lt;/p&gt;

&lt;p&gt;What worked was moving the check &lt;em&gt;out&lt;/em&gt; of the writer. The editor now walks through each worked example, checks it against the article's own rules, and fixes the result from the example's own inputs. Same drafts, blind comparison: 4 wins, 1 tie, 0 losses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let the generators write. Make a separate stage check.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What replaces the stack trace
&lt;/h2&gt;

&lt;p&gt;If errors won't tell you, you need other signals. This is what I use now.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Look for outputs sitting exactly on a limit.&lt;/strong&gt; One output at exactly 280 characters is a coincidence. A pile of them is truncation. It's one short query, and it's what showed me how big this was:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt;
  &lt;span class="nb"&gt;count&lt;/span&gt;&lt;span class="cm"&gt;(*) filter (where length(note) = 240) as at_limit,
  count(*)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;
&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;content_briefs&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nf"&gt;jsonb_array_elements_text&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="n"&gt;brief_json&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'notesForGenerator'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;note&lt;/span&gt;
&lt;span class="k"&gt;where&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;created_at&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;now&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="kt"&gt;interval&lt;/span&gt; &lt;span class="s1"&gt;'14 days'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;at_limit&lt;/code&gt; isn't close to zero, the model isn't finishing its sentences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't put limits where the model can cut.&lt;/strong&gt; The fix removes &lt;code&gt;maxLength&lt;/code&gt; from the schema we send. Each field's description says "At most N characters." Our own code checks the length after the call and runs one repair pass if it's over:&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;function&lt;/span&gt; &lt;span class="nf"&gt;textSchema&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;limit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;BriefTextLimit&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;JsonSchema&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// No maxLength: strict outputs would stop mid-word to obey it.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="kd"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"string"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;description&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sb"&gt;`At most ${limit.max} characters.`&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;// After the call: our own Zod check. Over the limit? One repair pass&lt;/span&gt;
&lt;span class="c1"&gt;// asks the model to shorten that field.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The limits also went up to what the writer actually needs (600 for an outline point, 800 for a note). Replayed on six sites first: nothing landed on a limit, and the one meta description that ran long (160) was repaired to 144. It shipped the same day. The first two real briefs after it had nothing on a limit, and notes ran up to 593 characters. That's how much the writer was missing.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Make links impossible to get wrong instead of checking them after.&lt;/strong&gt; The planner now picks links by ID (L1, L2…) from the same list the link check uses, and code turns the IDs into paths. On replay, 14 of 14 links reached the page they were meant for.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Replay before you ship.&lt;/strong&gt; Every prompt or schema change gets replayed offline against stored briefs and drafts first. It's cheaper than finding out on a customer's site, and it's the only way to see every case at once instead of one symptom per bug report.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Compare blind.&lt;/strong&gt; Old output vs new, labels hidden. If you know which one is "the fix", you'll find a reason to like it.&lt;/p&gt;

&lt;p&gt;Blind isn't enough on its own, either. In one model bake-off, I had three judges rank the same articles, labels hidden and order shuffled. Claude's judge put the two Claude-written articles first. GPT's judge put the GPT article first. Gemini, the only one with no horse in the race, sided with Claude.&lt;/p&gt;

&lt;p&gt;Nobody told them who wrote what. They just liked the sound of their own voice. (Relatable, honestly.)&lt;/p&gt;

&lt;p&gt;That's one topic, so it proves nothing. But if you use AI judges, use more than one company's.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where this approach falls short
&lt;/h2&gt;

&lt;p&gt;I don't want to oversell this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Five-article blind tests are a reading, not a measurement.&lt;/strong&gt; They caught real regressions. But 4–1 on five topics wouldn't survive a statistics class. They tell you which way to lean, not how big the effect is.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I still can't see how an article actually performs.&lt;/strong&gt; Right now, a prompt change gets judged on how the drafts read, not on how they do in search. Keeping every version of every article (the first step toward that) is still being built.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strict schemas are still worth it.&lt;/strong&gt; Structured outputs mean I never parse broken JSON, and that's a big deal. The limit was the problem, not the schema.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Some failures are loud, and that's fine.&lt;/strong&gt; Auth, billing and database errors still throw, still hit Sentry, still alert me. Normal engineering still applies. It just doesn't cover the part that matters most here: whether the article got worse.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd do in your pipeline
&lt;/h2&gt;

&lt;p&gt;If you're chaining LLM calls, check these this week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove &lt;code&gt;maxLength&lt;/code&gt; from any schema a model fills in. State the limit in the description and check it in your own code.&lt;/li&gt;
&lt;li&gt;Count outputs that land &lt;em&gt;exactly&lt;/em&gt; on a limit. That number should be close to zero.&lt;/li&gt;
&lt;li&gt;Find every guard that deletes or skips on failure. Make each one log what it dropped, with a counter you actually look at.&lt;/li&gt;
&lt;li&gt;Count token budgets in tokens, not characters, and test them with a non-Latin language.&lt;/li&gt;
&lt;li&gt;When the model gets something wrong, fix it in a checking stage, not with another rule for the generator.&lt;/li&gt;
&lt;li&gt;Replay stored inputs and compare blind before every prompt change.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  So why is this harder?
&lt;/h2&gt;

&lt;p&gt;Here's my honest answer.&lt;/p&gt;

&lt;p&gt;It's not that LLMs are random. The truncation was perfectly deterministic. Same limit, same cut, every time.&lt;/p&gt;

&lt;p&gt;It's that "correct" stopped being something code can check. A normal system is either right or it throws. A pipeline like this has a third state: valid, passing, and worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Loud failures vs quiet ones.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every guard I added made the pipeline safer from crashing, and better at hiding its mistakes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In an LLM pipeline, HTTP 200 doesn't mean it worked.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This pipeline is &lt;a href="https://roylevy.dev/work/nichepressa/case-study" rel="noopener noreferrer"&gt;NichePressa&lt;/a&gt;, the content engine I built and run on my own sites.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Running LLM calls in a chain? I'd love to hear what's quietly breaking in yours, and how you caught it. &lt;a href="https://roylevy.dev/contact" rel="noopener noreferrer"&gt;Send me a note&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://roylevy.dev/blog/llm-pipeline-silent-failures" rel="noopener noreferrer"&gt;roylevy.dev&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>architecture</category>
      <category>debugging</category>
    </item>
    <item>
      <title>My Google sign-up worked every time I tested it. My first two real users got nothing.</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Tue, 10 Nov 2026 08:17:30 +0000</pubDate>
      <link>https://dev.to/roylevy/my-google-sign-up-worked-every-time-i-tested-it-my-first-two-real-users-got-nothing-5d1l</link>
      <guid>https://dev.to/roylevy/my-google-sign-up-worked-every-time-i-tested-it-my-first-two-real-users-got-nothing-5d1l</guid>
      <description>&lt;p&gt;&lt;em&gt;I tested from the app. They started from the homepage. One cookie, two hosts.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In my last post, I deleted 12,852 lines of AI fact-checking because it caught nothing real.&lt;/p&gt;

&lt;p&gt;This one is smaller. One cookie.&lt;/p&gt;

&lt;p&gt;But it hurt more.&lt;/p&gt;

&lt;p&gt;I finally turned on paid ads for my product. Two people clicked and signed up with Google.&lt;/p&gt;

&lt;p&gt;Neither of them got in.&lt;/p&gt;

&lt;p&gt;So let's talk about it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup everybody has
&lt;/h2&gt;

&lt;p&gt;Nothing fancy here. You've probably built this exact thing:&lt;/p&gt;

&lt;p&gt;Marketing pages on &lt;code&gt;example.com&lt;/code&gt;.&lt;br&gt;
The app on &lt;code&gt;app.example.com&lt;/code&gt;.&lt;br&gt;
Supabase auth. Google OAuth. The PKCE flow.&lt;/p&gt;

&lt;p&gt;I tested sign-up many times. It always worked.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So why did it fail for the only two people who mattered?&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What actually happened
&lt;/h2&gt;

&lt;p&gt;Step by step:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The "Get started" button on the marketing page linked to a relative &lt;code&gt;/login&lt;/code&gt;. So the login page opened on &lt;code&gt;example.com&lt;/code&gt;. Not on the app host.&lt;/li&gt;
&lt;li&gt;The user clicks "Continue with Google". The Supabase client creates a code verifier and saves it in a cookie. A host-only cookie, on &lt;code&gt;example.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Google sends them back to the callback, which lives on &lt;code&gt;app.example.com/auth/callback&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;The callback tries to exchange the code for a session. The verifier cookie isn't there. It belongs to the other host. Error: &lt;code&gt;pkce_code_verifier_not_found&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;My error handling turned that into &lt;code&gt;/login?error=other_browser&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So the user was told they had switched browsers.&lt;/p&gt;

&lt;p&gt;They hadn't.&lt;/p&gt;

&lt;p&gt;They did everything right. My app blamed them for my bug.&lt;/p&gt;
&lt;h2&gt;
  
  
  The sneaky part
&lt;/h2&gt;

&lt;p&gt;Here's the thing that kept me from seeing it.&lt;/p&gt;

&lt;p&gt;Supabase had already created the user before the exchange failed.&lt;/p&gt;

&lt;p&gt;So my &lt;code&gt;auth.users&lt;/code&gt; table had two shiny new rows. No session. No profile. No workspace.&lt;/p&gt;

&lt;p&gt;From the outside, it looked like two people signed up and left. A marketing problem. "Maybe the onboarding is too long." "Maybe the pricing scared them."&lt;/p&gt;

&lt;p&gt;It wasn't a marketing problem.&lt;/p&gt;

&lt;p&gt;It was a cookie problem wearing a marketing problem's clothes.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why I never caught it
&lt;/h2&gt;

&lt;p&gt;I always started from the app host.&lt;/p&gt;

&lt;p&gt;And my browser was already signed in, so I never ran the real path: logged out, from the marketing page, click the big button.&lt;/p&gt;

&lt;p&gt;I tested the path &lt;em&gt;I&lt;/em&gt; take every day.&lt;/p&gt;

&lt;p&gt;My users took a different one.&lt;/p&gt;
&lt;h2&gt;
  
  
  How I found it
&lt;/h2&gt;

&lt;p&gt;Two checks, both boring, both worth it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Compare users against sessions and profiles.&lt;/strong&gt; Two users with zero sessions. That's not "they left". That's "they never got in".&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split the request logs by host.&lt;/strong&gt; The login page was served on the marketing host. The callback was on the app host.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you see the two hosts next to each other, it's obvious.&lt;/p&gt;

&lt;p&gt;Before that, it's invisible.&lt;/p&gt;
&lt;h2&gt;
  
  
  The fix: one host owns login
&lt;/h2&gt;

&lt;p&gt;The fix is one rule.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Login starts and ends on the same host.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The proxy (Next.js middleware, now &lt;code&gt;proxy.ts&lt;/code&gt;) checks every request before anything else. If it's a login or auth path on the wrong host, it sends the user to the app host:&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;// lib/site/origins.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;authOnAppHostRedirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;requestHost&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&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;pathname&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;search&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;configuredAppOrigin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&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;=&lt;/span&gt; &lt;span class="nf"&gt;appOrigin&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="kt"&gt;string&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="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;configuredAppOrigin&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;requestHost&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;null&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;pathname&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;"/login"&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;pathname&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startsWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/auth/"&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="kc"&gt;null&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="no"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;configuredAppOrigin&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="no"&gt;LOCAL_HOSTNAMES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;has&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;hostname&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="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// leave localhost alone&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;requestHost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&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;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;host&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;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="sb"&gt;`${app.origin}${pathname}${search}`&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;// proxy.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;proxy&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;NextRequest&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;appHostUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;authOnAppHostRedirect&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="n"&gt;headers&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="s2"&gt;"x-forwarded-host"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="n"&gt;request&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="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"host"&lt;/span&gt;&lt;span class="p"&gt;)&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="n"&gt;nextUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pathname&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="n"&gt;nextUrl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&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;appHostUrl&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// 308 keeps POST (the login server action) as POST.&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;redirect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;appHostUrl&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;308&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 usual auth gate&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two small details I'd copy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;308, not 301 or 302.&lt;/strong&gt; The login form posts a server action. A 301 or 302 can turn that POST into a GET. A 308 keeps it a POST.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;x-forwarded-host&lt;/code&gt; first.&lt;/strong&gt; Behind a proxy or CDN, the &lt;code&gt;host&lt;/code&gt; header your app sees isn't always the one the user typed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now the login page only ever renders on &lt;code&gt;app.example.com&lt;/code&gt;. The cookie and the callback always match.&lt;/p&gt;

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

&lt;p&gt;You can also set the cookie on the parent domain, &lt;code&gt;.example.com&lt;/code&gt;, so both hosts can read it.&lt;/p&gt;

&lt;p&gt;That works too.&lt;/p&gt;

&lt;p&gt;But then your auth cookies are shared with every subdomain you have now, and every one you add later. Docs site, status page, that preview deploy you forgot about.&lt;/p&gt;

&lt;p&gt;Having one host own login keeps the cookie where it is.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd check in your app today
&lt;/h2&gt;

&lt;p&gt;If you have a marketing site and an app on different hosts, five minutes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;[ ] Does every "Sign up" and "Log in" link on your marketing pages point to the app host? Absolute URLs, or a redirect.&lt;/li&gt;
&lt;li&gt;[ ] Does OAuth start on the same host as the callback?&lt;/li&gt;
&lt;li&gt;[ ] Do you map auth errors to one friendly message? "Use the same browser" hid the real cause for me.&lt;/li&gt;
&lt;li&gt;[ ] Can you see half-made sign-ups? Query users with no session and no profile. A sign-up count won't show them.&lt;/li&gt;
&lt;li&gt;[ ] Have you tested sign-up &lt;strong&gt;logged out, from the marketing page, in a clean browser profile&lt;/strong&gt;? Not from the app. From where real users start.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Here's my honest answer
&lt;/h2&gt;

&lt;p&gt;Was this a hard bug? No.&lt;/p&gt;

&lt;p&gt;Was it an expensive one? Yes. Those were my first sign-ups from paid ads. I emailed both, apologized, and offered a free month.&lt;/p&gt;

&lt;p&gt;The code wasn't the problem. My testing was.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The path you test vs the path they take.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your users don't start where you start.&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;This happened while building &lt;a href="https://nichepressa.com" rel="noopener noreferrer"&gt;NichePressa&lt;/a&gt;, an agent that writes and publishes posts into Git-based blogs.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Got bitten by cookies across subdomains too? I'd love to hear what else quietly breaks in that setup. Drop it in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>supabase</category>
      <category>webdev</category>
      <category>security</category>
    </item>
    <item>
      <title>I Spent 8 PRs Fixing My AI Fact-Checker. Then I Deleted All 12,852 Lines.</title>
      <dc:creator>Roy Levy</dc:creator>
      <pubDate>Sat, 07 Nov 2026 20:42:59 +0000</pubDate>
      <link>https://dev.to/roylevy/i-spent-8-prs-fixing-my-ai-fact-checker-then-i-deleted-all-12852-lines-a1a</link>
      <guid>https://dev.to/roylevy/i-spent-8-prs-fixing-my-ai-fact-checker-then-i-deleted-all-12852-lines-a1a</guid>
      <description>&lt;p&gt;&lt;em&gt;I asked AI to check AI. It cost more, caught nothing, and broke good articles.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I run a few product sites where AI writes the articles. Power stations, gear, that kind of thing. The articles go straight into the site's Git repo as MDX.&lt;/p&gt;

&lt;p&gt;Product articles have one job. Get the specs right.&lt;/p&gt;

&lt;p&gt;Battery capacity. Number of ports. Charge time. One wrong number and the article is useless. Worse, it's confidently wrong, and readers notice.&lt;/p&gt;

&lt;p&gt;So I did the responsible thing. I added an AI fact check.&lt;/p&gt;

&lt;p&gt;Every article got researched on the web. Every claim got checked against the research. If something didn't match, the check blocked the article or tried to fix it.&lt;/p&gt;

&lt;p&gt;Sounds great, right?&lt;/p&gt;

&lt;h2&gt;
  
  
  Eight PRs of whack-a-mole
&lt;/h2&gt;

&lt;p&gt;It kept blocking good articles.&lt;/p&gt;

&lt;p&gt;I patched it. It found a new way to be wrong. I patched that. It found another one.&lt;/p&gt;

&lt;p&gt;8 PRs in a row. Each one fixing the last false alarm.&lt;/p&gt;

&lt;p&gt;At some point I stopped patching and did what I should have done on day one. I replayed the check over everything I had saved. &lt;strong&gt;1,075 lines from real articles.&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;0&lt;/strong&gt; real errors caught&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;8&lt;/strong&gt; false alarms&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;3&lt;/strong&gt; "auto-fixes" that turned a correct line into a wrong one&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Read that again. It caught nothing, and it broke more than it fixed.&lt;/p&gt;

&lt;p&gt;And the bill? &lt;strong&gt;61%&lt;/strong&gt; of what the check cost was the web research step. Most of what it found was data already sitting in the product catalog.&lt;/p&gt;

&lt;p&gt;So I was paying one LLM to go find numbers I already had, so a second LLM could compare them with numbers a third LLM had typed.&lt;/p&gt;

&lt;p&gt;That's not quality control.&lt;/p&gt;

&lt;p&gt;That's an expensive game of telephone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stop letting the LLM type numbers
&lt;/h2&gt;

&lt;p&gt;The fix wasn't a better checker.&lt;/p&gt;

&lt;p&gt;The fix was taking the numbers away from the LLM.&lt;/p&gt;

&lt;p&gt;Before, the writer produced prose with the numbers baked in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The SOLIX C300 has a 288Wh battery, enough for a laptop and a few phones.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now it writes a variable instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;The SOLIX C300 has a &amp;lt;Spec item="power-stations/anker-solix-c300" field="specifications.capacityWh" /&amp;gt;Wh
battery, enough for a laptop and a few phones.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The real value gets filled in from the catalog on save, preview, export, and push. The &lt;code&gt;field&lt;/code&gt; is just a path into the item's JSON (every site's catalog looks different, so it has to be flexible).&lt;/p&gt;

&lt;p&gt;The rule is simple:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The catalog is the source of truth. The LLM writes the sentence around it.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If a number is wrong, it's wrong in exactly one place. Fix it in the catalog, and every article is fixed.&lt;/p&gt;

&lt;h2&gt;
  
  
  "Okay, but what if I check the catalog instead?"
&lt;/h2&gt;

&lt;p&gt;Yes. I tried that too. Smaller scope, same idea: compare each catalog item with the manufacturer's page.&lt;/p&gt;

&lt;p&gt;First live run: 5 products, &lt;strong&gt;$0.85&lt;/strong&gt; (that's &lt;strong&gt;$0.17 per product&lt;/strong&gt;), 10 differences flagged.&lt;/p&gt;

&lt;p&gt;5 were real. I fixed them by hand.&lt;/p&gt;

&lt;p&gt;The other 5:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;LFP&lt;/code&gt; vs &lt;code&gt;LiFePO4&lt;/code&gt;. Same battery chemistry, different name.&lt;/li&gt;
&lt;li&gt;A 0–80% fast-charge time compared with a full charge.&lt;/li&gt;
&lt;li&gt;A group of USB-C ports read as one port.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Every one of those is fixable with a special case. And I already knew how that story ends. Every special case exposes the next edge case.&lt;/p&gt;

&lt;p&gt;Same trap. Smaller scale.&lt;/p&gt;

&lt;p&gt;I deleted that one too.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where an AI check still makes sense
&lt;/h2&gt;

&lt;p&gt;To be fair, this isn't a "never let AI check anything" post.&lt;/p&gt;

&lt;p&gt;The catalog check did find 5 real mistakes. Catalogs that were written fast (especially by AI) are exactly where errors sneak in.&lt;/p&gt;

&lt;p&gt;So if I ever bring it back, it'll be a one-time check when a catalog is first imported. Run it once, show the differences, let a human decide. Not a robot that runs on every article and edits things on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  What I'd do if you're building something similar
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;If a fact exists as data, &lt;strong&gt;insert it&lt;/strong&gt;. Don't ask an LLM to restate it.&lt;/li&gt;
&lt;li&gt;Before you patch a check, &lt;strong&gt;replay it over all your saved data&lt;/strong&gt;. One live failure tells you nothing about the rate.&lt;/li&gt;
&lt;li&gt;Count the cost per catch, not just the cost per run.&lt;/li&gt;
&lt;li&gt;Make deleting a feature an option on the table, not a failure.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  So, was it worth it?
&lt;/h2&gt;

&lt;p&gt;Here's my honest answer.&lt;/p&gt;

&lt;p&gt;The check made the product &lt;em&gt;feel&lt;/em&gt; safer. The variables made it &lt;em&gt;actually&lt;/em&gt; safer.&lt;/p&gt;

&lt;p&gt;The final diff was &lt;strong&gt;+147 / −12,852&lt;/strong&gt; across 79 files. Less code, lower bills, and the articles got more accurate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Don't make the AI remember the facts. Make it impossible to get them wrong.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;(All of this happened while building &lt;a href="https://nichepressa.com" rel="noopener noreferrer"&gt;NichePressa&lt;/a&gt;, the engine that writes those articles and commits them to the repo. If you run a Git-based blog, that's what it's for.)&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Where do you draw the line between what the LLM writes and what has to come from data? I'd love to hear how you handle it. Drop it in the comments.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
