Export API
High-level API
We're providing a built-in high-level APIs for the most critical export scenarios.
Recipes
API Reference
Assets export explained
If you have a specific scenario in mind, you can utilize low-level APIs in a similar manner to how we use them.
Our primary export APIs follow the flow outlined below:
- Create an export context with createExportContext
- Collect Figma elements to export (it could be any logic)
- Resolve exported assets with resolveExportedAssets
- Download exported assets with downloadExportedAssets
- Write downloaded assets to disk with writeDownloadedAssets
ts
import {
createExportContext,
resolveExportedAssets,
downloadExportedAssets,
writeDownloadedAssets
} from '@figma-export/core';
const ctx = createExportContext({
/* ... */
});
const myElements = await collectSomeFigmaElements();
// Prepare assets for download
const downloadable = await resolveExportedAssets({
ctx,
items: myElements,
exportAs: 'svg',
getItemMeta: ({ id, name }) => ({
id,
name,
fileId: 'my-file-id'
})
});
// Download assets
const downloadedItems = await downloadExportedAssets({
ctx,
items: downloadable
});
// Write assets to disk
await writeDownloadedAssets({
ctx,
items: downloadedItems,
getFileNameCtx: () => null
});