Core Concepts

Export System

Export current Phorm designs as SVG, HTML, JSON, or React. Raster and PDF output are shown as degraded unless a downstream renderer is configured.

Export Formats

SVG.svg
Scalable Vector Graphics. Infinite resolution, editable, smallest file size for vector content.
Best for: Icons, logos, illustrations, web graphics
transparencyvector pathstext as pathsgradients
HTML.html
Standalone markup preview generated from the current canvas elements.
Best for: Browser preview, handoff, lightweight design review
inline layouteditable markuplocal download
JSON.json
Portable design session data for import, local backup, and agent handoff.
Best for: Design data exchange, local drafts, reproducible generation
canvas elementsmetadatatheme tokens
React.tsx
React component scaffold generated from the current composition.
Best for: Frontend handoff and component composition review
component codestyle valueslocal download
Preset Dimensions
Canvas sizes used by local export and future renderer adapters
PresetDimensionsAspect RatioPlatform
Open Graph1200 x 6301.91:1General web sharing
Twitter Card1200 x 6002:1Twitter/X posts
Facebook1200 x 6281.91:1Facebook posts
LinkedIn1200 x 6271.91:1LinkedIn posts
Instagram Square1080 x 10801:1Instagram feed
Instagram Story1080 x 19209:16Instagram/TikTok stories
YouTube Thumbnail1280 x 72016:9YouTube videos
Favicon512 x 5121:1Website favicon
Export Options
Configure export settings for optimal results
interface ExportOptions {
  // Format selection
  format: "svg" | "html" | "json" | "react"
  
  // Dimensions
  width?: number          // Custom width, max 8192
  height?: number         // Custom height, max 8192
  
  // Appearance
  transparent?: boolean   // Transparent SVG background
  
  // Response mode
  download?: boolean      // Return an attachment instead of JSON content
}
Export API
Programmatic export via REST API
// Basic export request
const response = await fetch('/api/v1/export', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer $PLATPHORM_API_KEY'
  },
  body: JSON.stringify({
    elements: currentCanvasElements,
    format: 'svg',
    width: 1200,
    height: 720,
    transparent: true
  })
})

const result = await response.json()
// {
//   ok: true,
//   data: {
//     format: "svg",
//     content: "<svg ...>",
//     traceId: "..."
//   }
// }
Client-Side Export
Export directly in the browser
import { useExport } from '@/hooks/use-export'

function MyComponent() {
  const { 
    exportDesign, 
    isExporting, 
    progress,
    lastExport 
  } = useExport()

  const handleExport = async () => {
    const result = await exportDesign({
      format: 'png',
      scale: 2,
      transparent: true
    })
    
    if (result.success) {
      // Auto-downloads the file
      console.log('Exported:', result.filename)
    }
  }

  return (
    <button onClick={handleExport} disabled={isExporting}>
      {isExporting ? `Exporting... ${progress}%` : 'Export PNG'}
    </button>
  )
}
Custom Export Presets
Save and reuse export configurations
// Save a local browser preset
savePreset({
  id: "blog-hero",
  name: "Blog Hero Image",
  format: "webp",
  width: 1200,
  height: 630,
  scale: 2,
  quality: 85,
  transparent: false,
  createdAt: new Date().toISOString()
})

// List saved presets from local browser storage
const presets = loadPresets()

// Delete a local preset
deletePreset("blog-hero")
Export History
Track and re-export previous exports
// Export history can be tracked locally when this helper is wired into a client flow.
addToHistory({
  id: crypto.randomUUID(),
  preset: "og-image",
  filename: "phorm-design.png",
  format: "png",
  timestamp: new Date().toISOString(),
  size: blob.size
})

const history = getHistory()

// Clear local browser history
clearHistory()
Best Practices
Tips for optimal export results

For Web

Use WebP for best quality/size ratio. SVG for icons and logos. PNG for images needing transparency.

For Social Media

Use the built-in presets for correct dimensions. Export at 2x scale for retina displays. Test on actual platforms.

For Print

Use SVG or HTML handoff in Phase 1. PDF and print-specific color management require a configured renderer adapter.

For Performance

Export only the formats needed for the current handoff. Server batch export is disabled until an adapter is configured.

Related Documentation