Setup

To use the Redirects API, install the @wix/redirects package using npm or Yarn:

Copy
1
npm install @wix/redirects

or

Copy
1
yarn add @wix/redirects

Then import { redirects } from @wix/redirects:

Copy
1
import { redirects } from '@wix/redirects'
Was this helpful?
Yes
No

About the Redirects API

Wix Headless provides you with the flexibility to create an app or site on any platform and take advantage of Wix's backend business solutions via APIs. However, for some processes, such as authentication and checkout, you can save time and effort by using standard frontend pages produced by Wix. The Redirects API enables you to temporarily redirect visitors from your external site to a Wix-managed page for these processes, and then return them to your site. These Wix-managed pages are seamlessly incorporated into the user experience of your external site.

With the Redirects API, you can:

  • Redirect a site visitor to a Wix authentication page, then have them redirected back to your external site with authorization credentials.
  • Take advantage of Wix frontend functionality by redirecting users to Wix-managed pages for bookings, eCommerce, events, and paid plans transaction checkouts.
  • Customize your flow, integrating Wix-managed pages alongside custom external pages. For example, use a Wix checkout with an external thank you page.

Before you begin

It's important to note the following points before starting to code:

  • After a redirect session for authentication, Wix returns visitors to the redirect URI you provide only if the full URI has been authorized in advance. Make sure to add approved authentication URIs in the Headless Settings menu in the Wix project dashboard.
  • After all other redirect sessions, Wix returns visitors to the post-flow URL you provide only if the domain has been authorized in advance. Make sure to add approved domains in the Headless Settings menu in the Wix project dashboard.

Terminology

  • Redirect session: A temporary redirection of a visitor from an external site to a Wix-managed page for a process such as authentication or checkout.
Was this helpful?
Yes
No

createRedirectSession( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a URL for redirecting a visitor from an external client site to a Wix page for Wix-managed functionality.

The createRedirectSession() function enables your external Wix Headless client site, built on any platform, to integrate Wix-managed frontend functionality for specific processes. For example, your site can temporarily redirect a visitor to Wix for authentication, or for a checkout process for a bookings, eCommerce, events, or paid plans transaction.

To initiate a redirect session:

  1. Call createRedirectSession() with the details required for Wix to take care of one specific process (for example, authentication or a bookings checkout). Provide one or more callback URLs, so Wix can redirect the user back to your site as appropriate when the process is over.
  2. Redirect your visitor to the URL provided in the response. This URL includes query parameters informing Wix where to redirect the visitor back to on your external site.
  3. Make sure the pages at the callback URLs you provided take care of the next stages in your visitor flow.
Params
optionsCreateRedirectSessionOptions
Options for creating a redirect session.
Response Object
CreateRedirectSessionResponse
Was this helpful?
Yes
No