WixProvider

Deprecated

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

The WixProvider component provides functionality for working with the Wix JavaScript SDK in a React project using the @wix/sdk-react package.

Note:

  • All @wix/sdk-react functionality must be wrapped inside a WixProvider component.
  • Don't explicitly create a WixProvider when using @wix/dashboard-react. The main withDashboard() function intializes a provider for you behind the scenes.

Props

NameTypeDescription
authAuthenticationStrategyThe authentication strategy to use for authenticating API calls, such as OAuthStrategy, AppStrategy, or APIKeyStrategy.
hostHostOptional. An API host. You only need to specify a host when using a client to access hosted modules, such as the dashboard module.

Note: In most scenarios, the React SDK is used on client environments such as browsers and mobile apps, and so shouldn't be initialized with an authentication strategy with administrative permissions, like the ApiKeyStategy. To learn more, see Authorization Strategies.

Examples

The following examples show how to pass the WixProvider the relevant authentication information for Wix Headless, Wix apps, and Wix apps with a dashboard page.

Authenticate with OAuth for Wix Headless

Copy

Authenticate with OAuth for Wix apps

Copy

Authenticate with the dashboard strategy

The dashboard.auth() authentication strategy provides an access token for the currently logged-in user in the Wix Dashboard. This token allows your code to access APIs using the permissions of the logged-in user, limited to the permissions granted to your app.

The dashboard module is designed for use within the Wix platform environment, granting access to Wix Dashboard frontend APIs, like showToast. To use this module, initialize the WixProvider with the host object obtained from dashboard.host().

Copy
Did this help?