Use JSX with Satori without React
npm install satori-jsx
import satori from 'satori-jsx/vite'
export default {
plugins: [satori()]
}
If you're using typescript, make sure to add the following to your tsconfig.json
:
{
"compilerOptions": {
"jsx": "preserve",
}
}
npm install -D @babel/plugin-syntax-jsx @babel/plugin-transform-react-jsx
Update your .babelrc
{
"plugins": [
"@babel/plugin-syntax-jsx",
[
"@babel/plugin-transform-react-jsx",
{
"runtime": "automatic",
"importSource": "satori-jsx"
}
]
]
}
For JSX types, it's best to use react's.
npm install -D @types/react @types/react-dom