Back to articles
URL Unfurling: How Slack, Discord and Twitter Generate Link Previews

URL Unfurling: How Slack, Discord and Twitter Generate Link Previews

via Dev.to Tutorialeatyou eatyou

You paste a URL in Slack. A second later, a rich card appears — title, description, image, favicon. Magic. But it's not magic. It's a well-defined process called URL unfurling . Every chat app, social platform, and messaging service does it. Understanding how it works makes you a better web developer — and helps you debug why your links sometimes look broken. Let's break it down. What Happens When You Paste a URL Here's the sequence, step by step: Step 1: Detection The app detects a URL pattern in your message. Most apps use a regex like: https?://[^\s]+ Some apps unfurl all URLs. Others only unfurl the first one. Slack unfurls up to 5 per message. Step 2: Server-Side Fetch The app's server (not your browser) makes an HTTP GET request to the URL. This is important — it means: The request comes from the app's IP, not yours JavaScript doesn't execute (no browser engine) The server follows redirects (usually up to 5-10 hops) There's a timeout (typically 3-10 seconds) GET https://example.c

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
2 views

Related Articles