You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21-2Lines changed: 21 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,27 @@ Under the hood, it handles layout calculation, font, typography and more, to gen
51
51
Satori only accepts JSX elements that are pure and stateless. You can use a subset of HTML
52
52
elements (see section below), or custom React components, but React APIs such as `useState`, `useEffect`, `dangerouslySetInnerHTML` are not supported.
53
53
54
+
#### Experimental: builtin JSX support
55
+
56
+
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.
57
+
58
+
```tsx
59
+
/**@jsxRuntime automatic */
60
+
/**@jsxImportSource satori/jsx */
61
+
62
+
importsatorifrom'satori';
63
+
import { FC, JSXNode } from'satori/jsx';
64
+
65
+
const MyComponent:FC<{ children:JSXNode }> = ({ children }) => (
66
+
<divstyle={{ color: 'black' }}>{children}</div>
67
+
)
68
+
69
+
const svg =awaitsatori(
70
+
<MyComponent>hello, world</MyComponent>,
71
+
options,
72
+
)
73
+
```
74
+
54
75
#### Use without JSX
55
76
56
77
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:
@@ -351,8 +372,6 @@ Multiple fonts can be passed to Satori and used in `fontFamily`.
351
372
> [!TIP]
352
373
> We recommend you define global fonts instead of creating a new object and pass it to satori for better performance, if your fonts do not change. [Read it for more detail](https://github.com/vercel/satori/issues/590)
353
374
354
-
355
-
356
375
#### Emojis
357
376
358
377
To render custom images for specific graphemes, you can use `graphemeImages` option to map the grapheme to an image source:
0 commit comments