@haus-tech/haus-storefront-companion
v3.6.1
Published
Haus storefront companion plugin
Readme
name: haus-storefront-companion title: Haus Storefront Companion Plugin description: Vendure plugin that exposes custom field definitions to the Admin and Shop APIs so storefronts can render custom fields dynamically. version: 3.6.0 tags: [vendure, plugin, custom-fields, storefront, graphql]
Haus Storefront Companion Plugin
The Haus Storefront Companion Plugin exposes the running Vendure instance's custom field definitions (not just their values) through the Admin and Shop GraphQL APIs. This lets a storefront discover, at runtime, which custom fields exist on each entity — their names, types, and metadata — so it can render forms and display custom data dynamically instead of hard-coding field lists.
Functionality
getCustomFieldsForEntity(entityName)— Returns the custom field configuration for a single entity (e.g.Product,Order,Customer).getAllCustomFields— Returns the custom field configuration for every entity that has custom fields, sorted by entity name.- API-aware visibility — On the Shop API, only fields marked
publicand notinternalare returned. The Admin API returns all fields. - Both APIs — The same two queries are available on the Admin and Shop APIs.
Use Cases
- Render custom-field-driven UI in a headless storefront without hard-coding the field list.
- Build a generic admin/editor UI that adapts to whatever custom fields are configured on the Vendure server.
- Introspect custom field metadata (type, label, options) at runtime.
Installation
Install the plugin package:
yarn add @haus-tech/haus-storefront-companionOr, if using npm:
npm install @haus-tech/haus-storefront-companionAdd the plugin to your Vendure configuration in
vendure-config.ts:import { HausStorefrontCompanionPlugin } from '@haus-tech/haus-storefront-companion' export const config = { plugins: [HausStorefrontCompanionPlugin.init({})], }Restart your Vendure server.
Usage
Get custom fields for a single entity
query {
getCustomFieldsForEntity(entityName: Product)
}Get all custom fields grouped by entity
query {
getAllCustomFields {
entityName
customFields
}
}customFields is returned as JSON, matching Vendure's CustomFieldConfig
shape (name, type, label, list, public, internal, etc.).
The queries are available on both the Admin API and the Shop API. On the Shop
API only fields marked public and not internal are returned.
Testing
- Run
yarn testto execute the tests. - Implement additional tests to cover your specific use cases.
Publish to NPM
Make sure you are logged in to NPM.
Build the plugin:
yarn buildPublish the plugin (releases are managed via Nx Release from the repo root):
npx nx release
