Badge Plugin
Storefront plugin config and UI primitives for reading and rendering product badges.
Disclaimer: This module depends on compatible plugin behavior being active in the consumer's Vendure backend instance. Configure the backend first, then register this plugin config in the storefront.
Purpose
Use this module when you need badge data in product/search queries and want reusable headless components for rendering badge positions and images.
Features
- Extends queries with badge fields for products and search results
- Exposes
VendureBadgePluginfor DataProviderpluginConfigs - Exposes
ProductBadgeheadless UI primitives (Root,Group,Item,Image) - Provides settings-driven badge position filtering
Installation
- npm
- Yarn
npm install @haus-storefront-react/vendure-plugin-configs
yarn add @haus-storefront-react/vendure-plugin-configs
Note: This is not a public package. Contact the Haus Tech Team for access.
API Reference
Components
ProductBadge
Headless badge primitives with Root, Group, Item, and Image for custom rendering.
Exports
VendureBadgePluginProductBadgeBadgetypeBadgeFeatures,BadgePluginRequests,BadgePluginSettingstypes
Basic Usage
Example 1: Register Plugin in Data Provider
Use this to configure and register the badge plugin in your provider pluginConfigs.
- React
- React Native
import { VendureBadgePlugin } from '@haus-storefront-react/vendure-plugin-configs/badge'
const pluginConfig = VendureBadgePlugin.init({
enableFeatures: {
showBadges: true,
},
settings: {
defaultPositions: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
availablePositions: {
productListItem: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
productDetail: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
imageCarousel: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
},
},
})
import { VendureBadgePlugin } from '@haus-storefront-react/vendure-plugin-configs/badge'
const pluginConfig = VendureBadgePlugin.init({
enableFeatures: {
showBadges: true,
},
settings: {
defaultPositions: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
availablePositions: {
productListItem: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
productDetail: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
imageCarousel: ['top-left', 'top-right', 'bottom-left', 'bottom-right'],
},
},
})
Example 2: Consume Plugin Functionality
Use this in application UI after the plugin has been registered.
- React
- React Native
import { ProductBadge } from '@haus-storefront-react/vendure-plugin-configs/badge'
export function ProductBadges({ product }) {
return (
<ProductBadge.Root product={product}>
{({ groupedBadges }) =>
Object.entries(groupedBadges).map(([position, badges]) => (
<ProductBadge.Group key={position} position={position}>
{badges.map((badge) => (
<ProductBadge.Item key={badge.id} badge={badge}>
<ProductBadge.Image badge={badge} />
</ProductBadge.Item>
))}
</ProductBadge.Group>
))
}
</ProductBadge.Root>
)
}
import { View } from 'react-native'
import { ProductBadge } from '@haus-storefront-react/vendure-plugin-configs/badge'
export function ProductBadges({ product }) {
return (
<ProductBadge.Root product={product}>
{({ groupedBadges }) =>
Object.entries(groupedBadges).map(([position, badges]) => (
<ProductBadge.Group key={position} position={position}>
{badges.map((badge) => (
<ProductBadge.Item key={badge.id} badge={badge}>
<View>
<ProductBadge.Image badge={badge} />
</View>
</ProductBadge.Item>
))}
</ProductBadge.Group>
))
}
</ProductBadge.Root>
)
}
Made with ❤️ by Haus Tech Team