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.

This article explains how to migrate your code for Velo APIs that have equivalent SDK modules.

Step 1 | Identify what to migrate

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.

Velo APIs fall into the following categories: APIs that have equivalent SDK modules: Migrate your code using the instructions in this article. APIs that don't have equivalent SDK modules, but the SDK supports their functionality: Rewrite your code using SDK modules that support the APIs' functionality. APIs for which the SDK doesn't yet support their functionality: Continue to use these Velo APIs alongside the SDK.

To learn more about finding Velo APIs' functionality in the SDK and which Velo APIs you should continue to use, see Velo to SDK API Mapping.

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
import { bookings } from "wix-bookings.v2"; //... const booking = await bookings.createBooking(bookingInfo);

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

Copy
import { bookings } from "@wix/bookings"; //... const booking = await bookings.createBooking(bookingInfo);

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

See also

Did this help?