Edge Functions for Share Previews and Crawler HTML

Published 2025-11-23 by Faraz Rahimi

SPA routes look empty to crawlers and chat apps. An edge function that injects title, image, and article text is how a public post actually exists.

Edge Functions for Share Previews and Crawler HTML

Tags: SEO, Netlify, Edge, React, unlisted

I learned the hard way that a React helmet tag does nothing for Slack unfurls. The crawler does not wait for your useEffect.

Now a Netlify edge function loads the published post and writes Open Graph tags plus a hidden copy of the article for language models and search engines. Humans still get the React app in #root.

Live data, not a rebuild

New posts should appear in the sitemap and in that HTML without me clicking deploy for each slug. The function reads the database at request time. Cache a couple of minutes, not a couple of weeks.

Do not cloak a different story

The hidden text should be the same post people read. If you show crawlers a fantasy, you will earn the wrong traffic and the wrong kind of attention.

Original post: https://farazrahimi.com/posts/edge-functions-for-share-previews-and-crawler-html