An Editor React Component (ERC) can use a Wix business solution context by calling the context's React hook in its own code. A Wix business solution context is a context that a Wix business solution provides, such as the Stores Product Context. It holds the business solution's current values, such as a product's price and stock, and functions for actions, such as adding the selected product to the cart.
A business solution provides its context on some of its own pages, for each item in some of its lists, and through Data Sources. In the Studio Two editor, a Data Source is what a Wix user attaches to a page, container, or section to give the elements inside it access to a context. When a Wix user places your ERC inside one of these areas, the ERC's code can read that context's values without the Wix user binding the data in the editor. To compare this approach with editor binding, see Component Integration Patterns.
Follow the instructions below to:
Make sure that:
package.json lists the business solution's package, such as @wix/stores. If it doesn't, install the package. For instructions, see Work with npm Packages.In Wix Business Solution Contexts, find the context that holds the values your component needs. Each context's introduction lists:
Each context's reference pages document the properties and functions the hook returns.
For the example, use the Product Context. Its hook is useProductContext(), imported from @wix/stores/context/product. It's available on a product page, under the Product Data Source, and in each Product Item of a Product List.
To use the context:
<component-folder>.tsx file under src/extensions/site/components/<component-folder>/.When a value in the context changes, the hook returns the new value and your component renders again. For example, the Product Context's pricing changes when a site visitor selects a different option.
The following component shows the price of the site visitor's current selection and an Add to Cart button:
The component still follows the rules for every ERC, such as passing id and className to its root element. For those rules, see Build an Editor React Component in Studio Two.
Declare each context your component uses in its manifest, so the site loads the context for your component. Importing the hook doesn't add the declaration for you.
To declare the context:
<component-folder>.extension.ts.resources.client and resources.editor, add a dependencies object with a contextDependencies array. resources.client covers the live site, and resources.editor covers the editor.'@wix/stores/context/product'.For example, to declare the Product Context:
For the other fields in resources, see About the Editor React Component Manifest.
Place the ERC where the context is available, and check that it shows the context's values.
To check the component:
A business solution page: Open the page, such as a product page.
A Data Source: Attach the Data Source to a page, container, or section:
For more about working with Data Sources in the editor, see Build a Data Source in Studio Two. To work in the Layers panel, see Studio Two Editor: Working with Layers. For Connect Source, see Connect to Source.
For the example, open the product page and choose a product in the product selector at the top of the canvas. Then ask Aria to place the price display on the page, and check that it shows the price of the product you chose. In Preview, check that clicking Add to Cart adds the product to the cart.
If the component shows placeholder content instead of the context's values, check component.preview.tsx. The editor loads this file on the canvas and in Preview, and it should render your component. You can ask Aria to update it. For what the file does, see Editor React Component Extension Files and Code.
Tip: If the editor shows an error instead of your component, the ERC isn't inside a page, Data Source, or list item that provides the context, so the context's hook throws. Move the ERC into an area that provides the context, or attach the Data Source to the page, container, or section that contains the ERC.
When you're ready, click Publish in the Studio Two editor. Your ERC ships with the published site and reads the context wherever it's placed inside a page, Data Source, or list item that provides it.
On the live site, check that the component works the same way it did in Preview.
Last updated: 2 November 2026