The React SDK provides pre-built components and hooks for displaying sustainability data in React applications.
Installation
Provider setup
Wrap your app with the HeyChocolateProvider:
For client-side usage, use a restricted API key with read-only permissions. Sensitive operations should go through your backend.
Hooks
useProduct
useImpactCalculation
useCartImpact
Components
CarbonBadge
ComparisonTable
ImpactBreakdown
SupplyChainViewer
Styling
All components accept className and style props. Default styles can be overridden with CSS variables: