<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yoginth on Medium]]></title>
        <description><![CDATA[Stories by Yoginth on Medium]]></description>
        <link>https://medium.com/@yoginth?source=rss-ddbbaea4c0af------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6QHnO6NvIuCPpTT3SUThGA.png</url>
            <title>Stories by Yoginth on Medium</title>
            <link>https://medium.com/@yoginth?source=rss-ddbbaea4c0af------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:08:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yoginth/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Serving Open Graph to Bots at hey.xyz: Our Client-Side SPA Approach]]></title>
            <link>https://medium.com/@yoginth/serving-open-graph-to-bots-at-hey-xyz-our-client-side-spa-approach-8361140cfd87?source=rss-ddbbaea4c0af------2</link>
            <guid isPermaLink="false">https://medium.com/p/8361140cfd87</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[bots]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[open-graph]]></category>
            <category><![CDATA[seo]]></category>
            <dc:creator><![CDATA[Yoginth]]></dc:creator>
            <pubDate>Sun, 20 Apr 2025 14:18:10 GMT</pubDate>
            <atom:updated>2025-04-20T14:18:10.544Z</atom:updated>
            <content:encoded><![CDATA[<p>At <a href="https://hey.xyz/">hey.xyz</a>, we built a client-side SPA using Vite and React Router 7. But this created a challenge — how do you serve proper metadata to social media crawlers and search engines when your app renders client-side?</p><p>Our solution was to create a dual-architecture system:</p><ol><li><strong>Main Web App</strong>: CSR app built with Vite + React Router 7 hosted on Cloudflare Pages</li><li><strong>OG Service</strong>: Minimal SSR Next.js app hosted on Railway that only renders metadata, no UI</li></ol><p>The secret sauce is a Cloudflare Worker that acts as our traffic cop. It checks incoming requests for bot user agents, and:</p><ul><li>If it’s a regular user: Pass them to our slick CSR app</li><li>If it’s a bot: Redirect to our specialized OG service</li></ul><p>This is the Cloudflare Interface where we connect the Worker with the Web app</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v-GlpO_SCaAwYnpzo87jmg.png" /></figure><p>We’ve set a generous cache policy (30 days) for bot responses since our metadata doesn’t change often.</p><p>This approach lets us keep our main app fast and interactive for actual users while still having proper social sharing and SEO. No need to sacrifice the benefits of a modern CSR app just to satisfy crawlers.</p><p>Here is the flow diagram of how things work</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1x5CX1i4zS0PLlMN1PLkhw.png" /></figure><p>Honestly, this pattern is so clean and efficient — we’re never going back to server-rendering our entire app just for bots.</p><p>This strategy helps us deliver millions of requests in a cost-efficient way, keeping our infrastructure costs low while providing the best experience for both users and search engines.</p><p>PS: Here is our Cloudflare worker code the checks for all requests</p><pre>const botRegex = /(Bot|Twitterbot|facebookexternalhit|LinkedInBot|Slackbot|Discordbot|TelegramBot|WhatsApp|Googlebot|Bingbot|Applebot)/i;<br><br>export default {<br>  async fetch(request) {<br>    const userAgent = request.headers.get(&quot;user-agent&quot;) || &quot;&quot;;<br><br>    // If not a bot, pass through<br>    if (!botRegex.test(userAgent)) {<br>      return fetch(request);<br>    }<br><br>    // If bot, rewrite to og.hey.xyz<br>    const url = new URL(request.url);<br>    const targetUrl = `https://og.hey.xyz${url.pathname}${url.search}`;<br><br>    const rewrittenRequest = new Request(targetUrl, {<br>      method: request.method,<br>      headers: request.headers,<br>      body: request.method !== &quot;GET&quot; &amp;&amp; request.method !== &quot;HEAD&quot; ? await request.text() : null,<br>      redirect: &quot;follow&quot;<br>    });<br><br>    const response = await fetch(rewrittenRequest);<br><br>    const newHeaders = new Headers(response.headers);<br>    newHeaders.set(&quot;Cache-Control&quot;, &quot;public, max-age=2592000, immutable&quot;);<br><br>    return new Response(response.body, {<br>      status: response.status,<br>      statusText: response.statusText,<br>      headers: newHeaders<br>    });<br>  }<br>};</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8361140cfd87" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>