Deprecated: Call Backend Code from the Frontend Using a jsw Web Module

Web modules allow you to write backend functions that you can easily call from the frontend.

Warning: Web modules defined using .jsw files are deprecated and you will soon be unable to create new .jsw files. However, existing .jsw web modules will continue work as expected. Switch to web module defined using .web.js files for your current and future projects.

The following describes how to create, export, and call web module functions.

Step 1 | Define a function in the backend

Add an exported function to an existing .jsw file.

Copy

Step 2 | Set permissions

Set permissions for each function in the web module if necessary. The default permission is Anyone.

You can set permissions in the Wix Editor or by editing the permissions.json file, depending on your development environment:

Step 3 | Call the function in the frontend

To call a web method from the frontend:

  1. Import the exported web method from the web module you created above:

    Copy
  2. Call the imported function:

    Copy

    Remember, web module functions are always asynchronous.

Did this help?