About Web Method Extensions

Web method extensions allow you to define functions in your app's backend that you can call from your frontend code.

You can import web methods into frontend files as you would any other function in your project. Wix handles the communication between your frontend and backend under the hood.

You can add a web method extension using the Wix CLI.

Web method permissions

Web methods allow you to specify the permissions required to call the function from the frontend.

Permission types:

  • Permissions.Anyone: Any site visitor can call the function.
  • Permissions.Admin: Only site admins can call the function.
  • Permissions.SiteMember: Only site members can call the function.

These are versions of the site visitor and site member identity types.

Be careful when selecting a permission, as exposing a function with the wrong permissions can create security risks.

Web methods vs HTTP functions

Web methods provide several advantages over using http functions to call your app's backend:

  • Strongly typed communication between client and server.
    • Type safety.
    • Auto complete for function names and parameters.
  • Intuitive, high-level communication between frontend and backend:
    • You can call your backend the same way you call functions in your frontend. You don't have to manually extract values from a request, serialize responses, or handle HTTP headers and query parameters as you would with API extensions.
    • Easier error handling. Instead of handling HTTP errors, you can throw exceptions like you would for any other function.
    • (CLI only) Hot module reloading (HMR) in your local preview on backend changes.

See also

Did this help?