将 JSX 和 HTML 渲染为 SVG 或图像。支持 160 多种 CSS 属性。支持直接替换 next/og。
Use takumi-js for images and animations, or takumi-pdf for PDF documents. The examples below use Bun to run JSX directly.
bun i takumi-js # PNG, JPEG, WebP, SVG, animations
bun i takumi-pdf # paged PDFSave this as image.tsx and run bun image.tsx to write a 1200 × 630 PNG.
import { render } from "takumi-js";
import { writeFile } from "node:fs/promises";
const image = await render(
,
{ width: 1200, height: 630 },
);
await writeFile("./output.png", image);Save this as document.tsx and run bun document.tsx to write an A4 PDF with a page-number footer.
import { render } from "takumi-pdf";
import { PageNumber, TotalPages } from "takumi-pdf/primitives";
import { writeFile } from "node:fs/promises";
const pdf = await render(
<main>
<h1>Invoice</h1>
<p>Total: $1,250.00</p>
</main>,
{
size: "a4",
footer: (
),
},
);
await writeFile("invoice.pdf", pdf);Takumi is a Rust rendering engine for markup and CSS. It handles layout, text shaping, compositing, and encoding without launching a browser. One component tree renders as an image, an animation, or a paged PDF.
text-fit grows or shrinks a headline to fill its line box, no measuring loop.text-wrap: balance balances lines in a headline. pretty reduces short last lines.@keyframes and animate-spin become WebP, APNG, GIF, or video frames.var(), calc(), and media queries.lang picks each language's own Han glyphs for the same code points.offset-path. background-clip: text and conic gradients paint it.filter: url(...), feTurbulence and feDisplacementMap included.corner-shape swaps round corners for squircle, bevel, scoop, notch, or superellipse(n).break-before: page, break-after: page, and break-inside: avoid.<PageNumber /> and <TotalPages /> count in CSS counter styles, trad-chinese-informal included.<thead> on every page.outline: true builds bookmarks from headings.takumi crate.| You are using | What changes |
|---|---|
satori |
Replace satori() with renderSvg(), or call render() for encoded image bytes. Compare the renderers. |
next/og |
Swap the ImageResponse import. Keep explicit Flexbox styles and compare the rendered output. Read the migration guide. |
| Puppeteer or Playwright for PDFs | Replace page.pdf() with render(). You must preload remote assets, and Takumi supports less CSS than Chrome. Read the migration guide. |
@react-pdf/renderer |
Replace Document, View, and Text with HTML elements and CSS. Browser viewers and some text controls have no equivalent. Read the migration guide. |
pdfkit |
Use JSX or HTML instead of positioning each line. Keep pdfkit when you need low-level drawing control. |
import { render } from "takumi-js";
import { googleFonts } from "takumi-js/helpers";
const image = await render(
,
{
width: 1200,
height: 630,
fonts: googleFonts([{ name: "Fraunces", weight: "100..900", axes: { opsz: "9..144" } }]),
},
);Rendering many images? Register the fonts once on a Renderer and reuse it. See Typography & Fonts.
next/og-compatible)import { ImageResponse } from "takumi-js/response";
export function GET() {
return new ImageResponse(
,
{ width: 1200, height: 630 },
);
}import { renderAnimation } from "takumi-js";
import { writeFile } from "node:fs/promises";
const animation = await renderAnimation({
width: 400,
height: 400,
fps: 30,
format: "webp",
scenes: [
{
durationMs: 1000,
node: (
),
},
],
});
await writeFile("./output.webp", animation);import { renderSvg } from "takumi-js";
import { writeFile } from "node:fs/promises";
const svg = await renderSvg(
,
{ width: 1200, height: 630 },
);
await writeFile("./output.svg", svg);cargo add takumiStart from the Rust example.
Compare Takumi and Satori for image formats, CSS support, runtime requirements, and migration examples. For PDFs, the renderer comparison records invoice benchmarks against @react-pdf/renderer and Puppeteer, with package versions and hardware.
Takumi supports a subset of browser CSS. PDF output rejects filter: blur(), drop-shadow(), and backdrop-filter. Keep Puppeteer when your output depends on page scripts or browser layout. Test your templates before switching renderers.
More projects in the showcase. Takumi is part of the Vercel OSS Program.
Takumi converts templates to a node tree, computes layout with Taffy, shapes text with Parley and Skrifa, and sends the layout to a raster, SVG, or PDF backend. See the node reference for the input format.
| Package | Use |
|---|---|
takumi-js |
JSX, HTML, and node trees to images, SVG, and animations. |
takumi-pdf |
JSX, HTML, and node trees to PDF documents. |
takumi-paint |
JSX, HTML, and node trees to a paint tree of used values. |
@takumi-rs/core |
Native Node.js bindings for direct node-tree rendering. |
@takumi-rs/wasm |
WebAssembly bindings for edge runtimes and browsers. |
@takumi-rs/helpers |
Template conversion, fonts, images, and emoji. |
takumi |
Rust crate for image rendering. |
| Takumi OG image (source) | Package OG card (source) |
|---|---|
| Prisma-style API card (source) | X-style social post (source) |
| Keyframe Animation (source) | shiki-image |
See more examples for invoices, e-invoices, Next.js, Cloudflare Workers, TanStack Start, Svelte, Rust, and ffmpeg keyframe animation.
Read CONTRIBUTING.md for local setup and the fixture workflow.
We welcome bug reports, feature requests, doc improvements, and new example integrations.
MIT or Apache-2.0
暂无开放 Issues,或尚未同步最近议题。