Baike.dev
All toolsTrendingOpen sourceNewsSubmit
Log in
< 返回工具列表
S

satori

> 前端框架
开源

Enlightened library to convert HTML and CSS to SVG

13.7K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Enlightened library to convert HTML and CSS to SVG

**Satori**: Enlightened library to convert HTML and CSS to SVG. > **Note** > > To use Satori in your project to generate PNG images like Open Graph images and social cards, check out our [announcement](https://vercel.com/blog/introducing-vercel-og-image-generation-fast-dynamic-social-card-images) and [Vercel’s Open Graph Image Generation docs →](https://vercel.com/docs/og-image-generation) > > To use it in Next.js, take a look at the [Open Graph Image Generation examples →](https://vercel.com/docs/og-image-generation/examples) ## Overview Satori supports the JSX syntax, which makes it very straightforward to use. Here’s an overview of the basic usage: ```jsx // api.jsx import satori from 'satori' const svg = await satori( , { width: 600, height: 400, fonts: [ { name: 'Roboto', // Use `fs` (Node.js only) or `fetch` to read the font as Buffer/ArrayBuffer and provide `data` here. data: robotoArrayBuffer, weight: 400, style: 'normal', }, ], }, ) ``` Satori will render the element into a 600×400 SVG, and return the SVG string: ```js '' ``` Under the hood, it handles layout calculation, font, typography and more, to generate a SVG that matches the exact same HTML and CSS in a browser.
## Documentation ### JSX Satori only accepts JSX elements that are pure and stateless. You can use a subset of HTML elements (see section below), or custom React components, but React APIs such as `useState`, `useEffect`, `dangerouslySetInnerHTML` are not supported. #### Experimental: builtin JSX support Satori has an experimental JSX runtime that you can use without having to install React. You can enable it on a per-file basis with [`@jsxImportSource` pragmas](https://www.typescriptlang.org/tsconfig/#jsxImportSource). In the future, it will autocomplete only the subset of HTML elements and CSS properties that Satori supports for better type-safety. ```tsx /** @jsxRuntime automatic */ /** @jsxImportSource satori/jsx */ import satori from 'satori'; import { FC, JSXNode } from 'satori/jsx'; const MyComponent: FC<{ children: JSXNode }> = ({ children }) => ( ) const svg = await satori( hello, world, options, ) ``` #### Use without JSX If you don't have JSX transpiler enabled, you can simply pass [React-elements-like objects](https://reactjs.org/docs/introducing-jsx.html) that have `type`, `props.children` and `props.style` (and other properties too) directly: ```js await satori( { type: 'div', props: { children: 'hello, world', style: { color: 'black' }, }, }, options ) ``` ### HTML Elements Satori supports a limited subset of HTML and CSS features, due to its special use cases. In general, only these static and visible elements and properties that are implemented. For example, the `` HTML element, the `cursor` CSS property are not in consideration. And you can't use `

核心特点

  • •TypeScript
  • •css
  • •image
  • •image-generation
  • •image-generator

> 标签

TypeScriptcssimageimage-generationimage-generator

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月9日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架
Baike.dev

baike.dev helps you discover great languages, frameworks, databases, DevOps and cloud-native tools.

Quick links

  • Home
  • All tools
  • Trending
  • Open source

About

  • About us
  • Community
  • News

Contribute

Found a great developer tool? Share it with the community.

Submit a tool
© 2026 baike.dev Developer EncyclopediaUpdated daily · Discover great developer tools