Setup

To use the React SDK, install the @wix/sdk-react package:

Copy
1
npm install @wix/sdk-react

Or

Copy
1
yarn add @wix/sdk-react

Then, import WixProvider, the authentication strategy to use, and any relevant hooks, like useWixModules:

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

Next, wrap your app in a WixProvider initialized with the appropriate authentication strategy:

Note: In most scenarios, the React SDK is used on client environments such as browsers and mobile apps. To ensure security, we recommend not to expose API keys in such environments given their administrative permissions. For more information, see Authorization Strategies.

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

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