$ pnpm install figma-to-html
import { FigmaParser } from "figma-to-html";
const figmaParser = new FigmaParser({
clientId: "clientId",
clientSecret: "clientSecret",
redirectUri: "redirectUri",
});
//single:figma url
figmaParser
.parse(url, { onProgress: (progress) => {} })
.then((htmlText) => {
console.log(htmlText);
})
.catch((error) => {
console.log(error);
});
//batch:figma url array
figmaParser
.parseBatch(urls, { onProgress: (progress) => {} })
.then((htmlText) => {
console.log(htmlText);
})
.catch((error) => {
console.log(error);
});
//image
figmaParser
.parseToImage(url)
.then((imageUrl) => {
console.log(imageUrl);
})
.catch((error) => {
console.log(error);
});
Option | Type | Default | Required | Description |
---|---|---|---|---|
clientId | string |
- | ✅ | figma clientId |
clientSecret | string |
- | ✅ | figma clientSecret |
redirectUri | string |
location.origin + location.pathname | figma redirectUri | |
tpl | boolean |
true | template | |
placeholderImage | string |
- | placeholder image url | |
imageResolver | (url: string, type: ImageType) => Promise<string> |
base64 image resolver | image resolver | |
onProgress | (progress: number) => void |
- | progress callback |
MIT