compile

Support

Client-side
Server-side

Examples

Emotion CSS

Pass { emotion: true } as the second compile option to merge and extract critical CSS using Emotion. Some libraries such as Chakra UI require this option to work correctly.

const html = await compile(<Component />, { emotion: true });
import { compile } from "@onedoc/react-print";
import { Button, ChakraProvider, extendTheme } from "@chakra-ui/react";

<>
  <ChakraProvider>
    <Button colorScheme="blue">Hello</Button>
  </ChakraProvider>
</>;