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.
At this stage, not all Velo APIs have SDK equivalents that can be used for site development or for app creation with Blocks.
To see what functionality is available in the SDK and what functionality is not yet available, see About Site Development.
The SDK is available through public npm packages. Each module in the SDK has its own package.
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
:
To create a booking using the SDK, you import bookings
from @wix/bookings
:
In this case, you simply need to change the source of the import from wix-bookings.v2
to @wix/bookings
.
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.