惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
小众软件
小众软件
F
Fortinet All Blogs
爱范儿
爱范儿
WordPress大学
WordPress大学
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
Google DeepMind News
Google DeepMind News
C
Check Point Blog
博客园 - 聂微东
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
Vercel News
Vercel News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
博客园 - 【当耐特】
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog
宝玉的分享
宝玉的分享
Jina AI
Jina AI
H
Hackread – Cybersecurity News, Data Breaches, AI and More

Vercel News

Vercel Open Source Program: Winter 2026 cohort How Notion Workers run untrusted code at scale with Vercel Sandbox How we run Vercel's CDN in front of Discourse From idea to secure checkout in minutes with Stripe Building Slack agents can be easy Scaling redirects to infinity on Vercel Advancing Python typing Gamma builds design-first agents with Vercel How Avalara turns pipe dreams into patent-pending with v0 Keeping community human while scaling with agents How OpenEvidence built a healthcare AI that physicians actually trust Security boundaries in agentic architectures Skills Night: 69,000+ ways agents are getting smarter Video Generation with AI Gateway We Ralph Wiggumed WebStreams to make them 10x faster How Stably ships AI testing agents in hours, not weeks How we built AEO tracking for coding agents Anyone can build agents, but it takes a platform to run them Introducing Geist Pixel The Vercel AI Accelerator is back with $6m in credits Making agent-friendly pages with content negotiation The Vercel OSS Bug Bounty program is now available Introducing the new v0 Run untrusted code with Vercel Sandbox, now generally available How Stripe built a game-changing app in a single flight with v0 How Sensay went from zero to product in six weeks AGENTS.md outperforms skills in our agent evals Agent skills explained: An FAQ Testing if "bash is all you need" AWS databases are now live on the Vercel Marketplace and v0
Introducing OG Image Generation: Fast, dynamic social car...
2022-10-10 · via Vercel News

3 min read

Create attention-grabbing, eye-catching OpenGraph imagery with code.

We’re excited to announce Vercel OG Image Generation – a new library for generating dynamic social card images. This approach is 5x faster than existing solutions by using Vercel Edge Functions, WebAssembly, and a brand new core library for converting HTML/CSS into SVGs.

Try it out in seconds.

Link to headingDynamic with limits

The engagement rate of Tweets that embed a card is 40% higher. While creating and sharing static social images isn’t difficult, handling dynamic images that need to be computed and generated instantly has had limits.

We released og-image.vercel.app four years ago to enable developers to dynamically generate open graph (OG) images by taking a screenshot of an HTML page inside of a Serverless Function. It’s since been used by thousands of developers to handle their social images. While functional, this approach came with some downsides:

  • Difficult: This solution required launching Chromium in a Serverless Function and taking a screenshot of the given HTML page with Puppeteer. Setting up these tools was hard to implement and often led to errors.

  • Slow: Because Chromium needs to be compressed to fit inside a Serverless Function and then decompressed on a cold boot, it’s very slow (~4 seconds on average). This can result in slow or broken social card images.

  • Expensive: Spinning up an entire browser just to take a screenshot was not efficient. This led to large Function sizes, which could be expensive and waste compute.

  • Large: Chromium has continued to grow in the past four years. Today, it's

    too large to fit in a Serverless Function.

Link to headingDynamic without limits

We’ve created a brand new open-source library @vercel/og to generate dynamic social card images. Vercel OG is:

  • Easy: No headless browser is needed. Using Vercel OG, you can define your images using HTML and CSS and automatically generate dynamic images from the generated SVGs.

  • Affordable: Vercel Edge Functions are ~160x cheaper than running Chromium in a Serverless Function. Further, generated images can be cached and stored at the Edge.

  • Fast: Vercel OG (500KB) is 100x more lightweight than Chromium + Puppeteer (50MB), which allows functions to start almost instantly. This helps ensure images are never too slow to generate and are always recognized by tools like the Open Graph Debugger.

Our results from usage on vercel.com/docs show Vercel OG is 5x faster in P99 TTFB (4.96s → 0.99s) and 5.3x faster in P90 (4s → 0.75s) than our previous version. Further, the code is colocated with the rest of the application for easier maintenance and updates.

Vercel OG also supports the following features:

  • Support for basic CSS layout, styling, and typography

  • Support for use in any framework or frontend application

  • Support for downloading font and emoji subsets from Google Fonts and other CDNs

Link to headingDynamic social images at the Edge

Vercel OG converts HTML and CSS into images.

The core engine, Satori, can be used in modern browsers, Node.js, and Web Workers. Building on top of the core engine, Vercel OG is able to be used inside Edge environments through WebAssembly to easily create social card images.

By leveraging the React component abstraction, social cards can be co-located with the rest of your frontend codebase. For example, inside a Next.js application:

pages/api/og.jsx

import { ImageResponse } from '@vercel/og'

export const config = {

runtime: 'experimental-edge',

}

export default function () {

return new ImageResponse(

(

<div

style={{

display: 'flex',

fontSize: 128,

background: 'white',

width: '100%',

height: '100%',

}}

>

Hello, World!

</div>

)

)

}

A Next.js Edge API Route to create a dynamic social card image.

Vercel OG automatically adds the correct Cache-Control headers to ensure the image is cached at the Edge after it’s been generated.

'content-type': 'image/png'

'cache-control': 'public, immutable, no-transform, max-age=31536000'

Caching headers from a generated Vercel OG image.

View more examples or read the API documentation.

Our social card generation previously used a compressed Chromium release to fit inside the 50mb Serverless Function limit. Due to the size of Chromium, images could take up to 5 seconds to generate, making sharing links feel slow. With Vercel OG, images render almost immediately.

Ben Schwarz

Link to headingTailwind CSS Support

Vercel OG also includes support for using Tailwind CSS with the tw prop.

<div tw="flex h-full items-center bg-white justify-center">

<div tw="bg-gray-50 flex">

<div tw="flex flex-col md:flex-row w-full py-12 px-4 md:items-center justify-between p-8">

<h2 tw="flex flex-col text-3xl sm:text-4xl font-bold tracking-tight text-gray-900 text-left">

<span>Ready to dive in?</span>

<span tw="text-indigo-600">Start your free trial today.</span>

</h2>

<div tw="mt-8 flex md:mt-0">

<div tw="flex rounded-md shadow">

<a href="#" tw="flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-5 py-3 text-base font-medium text-white">Get started</a>

</div>

<div tw="ml-3 flex rounded-md shadow">

<a href="#" tw="flex items-center justify-center rounded-md border border-transparent bg-white px-5 py-3 text-base font-medium text-indigo-600">Learn more</a>

</div>

</div>

</div>

</div>

</div>

An example Vercel OG image, modified from the Tailwind UI marketing section.

The example OG image using Tailwind CSS with Vercel OG.

The example OG image using Tailwind CSS with Vercel OG.

View this example in the Vercel OG Playground.

Link to headingDynamic ticket images for Next.js Conf

We were able to put Vercel OG Image to the test at Next.js Conf by creating dynamic ticket images for every attendee.

For over 100,000 tickets, we’ve seen images generated on average in 800ms. That sub-second response includes loading two custom fonts, two external requests to fetch the GitHub avatar and ticket background images, as well as two embedded SVG images.

Since we have the power of CSS, it’s easy to handle wrapping names that could break the layout, as well as supporting special characters outside of the font glyph range.

With Vercel OG, you can use the power of CSS to wrap layouts, as well as dynamically fetch and subset fonts from CDNs on the fly.

With Vercel OG, you can use the power of CSS to wrap layouts, as well as dynamically fetch and subset fonts from CDNs on the fly.

Link to headingTry Vercel OG Image Generation

Vercel OG Image Generation using Vercel Edge Functions is available today in public beta.