At hey.xyz, the challenge of serving proper metadata to social media crawlers and search engines when using a client-side SPA built with Vite and React Router 7 was addressed.
A dual-architecture system was implemented, consisting of the main web app as a CSR app built with Vite + React Router 7, and a separate OG Service as a minimal SSR Next.js app that only renders metadata.
A Cloudflare Worker acts as a traffic cop, redirecting bot requests to the specialized OG Service, while allowing regular user requests to access the CSR app.
This approach ensures a fast and interactive experience for users, while still providing proper social sharing and SEO capabilities.