Setup

To use the React SDK, install the @wix/sdk-react package using npm or Yarn:

Copy
1
npm install @wix/sdk-react

or

Copy
1
yarn add @wix/sdk-react

Then import WixProvider along with other functionality you need from @wix/sdk-react, including an authentication strategy and the hooks you'll use:

Copy
1
import { WixProvider, OAuthStrategy, useWixModules } from '@wix/sdk-react';

Next, add a WixProvider to your React project an set the authentication information:

Copy
1
<WixProvider
2
auth={OAuthStrategy({
3
clientId: '<CLIENT_ID>',
4
})}
5
></WixProvider>

Finally, call the useWixModules() hook within the WixProvider to get an initialized instance of a Wix SDK module and call its functions:

Copy
1
import { products } from '@wix/stores';
2
3
//...
4
5
const { queryProducts } = useWixModules(products);
6
7
const { items: productList } = await queryProducts().find();
Was this helpful?
Yes
No