Setup

Deprecated

This module is deprecated. For more information, see Migrating from sdk-react.

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

Copy
npm install @wix/sdk-react

Or

Copy
yarn add @wix/sdk-react

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

Copy
import { WixProvider, OAuthStrategy, AppStrategy, 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
import { products } from "@wix/stores"; //... const { queryProducts } = useWixModules(products); const { items: productList } = await queryProducts().find();
Did this help?