Migrate from Velo to the SDK

You can now use the Wix JavaScript SDK instead of the Velo API for most functionality when developing sites or building apps with Blocks.

You are encouraged to start using the SDK in all new and ongoing development projects. Although your existing code written using the Velo API will continue to work, you may want to migrate that code to use the SDK . Since the current SDK closely mirrors the latest module versions in the Velo API, migration is typically straightforward.

Step 1 | Identify what to migrate

At this stage, not all Velo APIs have SDK equivalents that can be used for site development or for app creation with Blocks.

  • For functionality that is not yet supported in the SDK, continue to use Velo APIs alongside the SDK.
  • For functionality that is supported in the SDK, follow the steps below.

To see what functionality is available in the SDK and what functionality is not yet available, see About Site Development.

Step 2 | Install packages

The SDK is available through public npm packages. Each module in the SDK has its own package.

  1. Determine which packages you need to install. Check the methods you use in the SDK reference to see which packages you need. Each module’s introductory documentation specifies the package you need to install.
  2. Install the packages you need using the editor or the Wix CLI.

Step 3 | Adjust import statements

As you need to import from the SDK package instead of from a Velo module, you need to adjust your existing import statements.

For example to create a booking using Velo, you import bookings from wix-bookings.v2:

Copy

To create a booking using the SDK, you import bookings from @wix/bookings:

Copy

In this case, you simply need to change the source of the import from wix-bookings.v2 to @wix/bookings.

Step 4 | Check for differences

In many cases, the SDK version of a method works exactly the same as the Velo version and no further changes are necessary. However, in some cases the SDK method may work slightly differently. This is especially true if you were using an older version of a Velo API.

If there are any differences, you will need to address them in your code. This usually means you need to pass different information when calling a method or handle the method’s response differently.

In some cases, this may mean calling a method from a different module than you are used to. Some common APIs that must be called differently when using the SDK are:

  • elevate(): This method is called from the auth submodule of the essentials module when using the SDK.
  • webMethod(): This method is called from the web-method module when using the SDK.
  • fetch(): You can use the native fetch() by calling this method on the frontend or backend without importing it when using the SDK.
  • getJSON(): This method does not exist in the SDK. You can either continue to use the Velo version for now, or you can convert your getJSON() calls to calls to fetch() instead. To get the JSON data from the fetch() response, call the json() method.

See also

Did this help?