TakumiTakumi

Quickstart

Render your first image with Takumi in under five minutes.

Three working examples, copy-paste runnable. Pick the one that matches your runtime.

Static OG image

import {  } from "takumi-js";

const  = await (
  < ="w-full h-full flex items-center justify-center bg-gradient-to-b from-blue-100 to-red-50">
    < ="text-6xl font-bold">Hello from Takumi</>
  </>,
  { : 1200, : 630 },
);

// `image` is a Uint8Array — pipe to disk, `Response`, or any writable stream.

Animated WebP

import {  } from "takumi-js/node";
import {  } from "takumi-js/helpers/jsx";

const  = new ();

const { ,  } = await (
  < ="w-full h-full flex items-center justify-center">
    < ="w-32 h-32 bg-blue-500 animate-spin rounded-lg" />
  </>,
);

const  = await .({
  : 400,
  : 400,
  : 30,
  : "webp",
  ,
  : [{ : 1000,  }],
});

Cloudflare Workers route

import {  } from "takumi-js/response";

export default {
  (: Request) {
    const  = new (.)..("name") ?? "world";

    return new (
      < ="w-full h-full flex items-center justify-center bg-slate-900 text-white">
        < ="text-7xl font-bold">Hello, {}</>
      </>,
      { : 1200, : 630 },
    );
  },
};
Edit on GitHub

Last updated on

On this page