Search code examples
velo

Clarification on instructions for backend Code in Wix


I'm trying to integrate backend code into a Wix site. Im not too picky about how I want to do this, or what language to write in (ideally, I have a locally-hosted Java code that I'd love to simply call). I wouldn't mind re-writing it in JavaScript though, or another language. But before I decide that I'm confused about my options. I can code but I'm new to the concepts like modules, APIs, & servers.

According to my research, back-end code with Wix is supposed to be easy (or at least do-able and not THAT complicated)....

From this webpage https://support.wix.com/en/article/corvid-calling-server-side-code-from-the-front-end-with-web-modules,

"Web modules are exclusive to Corvid and enable you to write functions that run server-side in the backend, and easily call them in your client-side code. With web modules you can import functions from backend into files or scripts in public, knowing they will run server-side. Corvid handles all the client-server communication required to enable this access."

And from this: https://www.sitepoint.com/what-is-wix-code/

"It’s serverless: All this added functionality comes in a serverless environment that lets you get your work done without any of the normal full-stack development headaches. Just code and go: Wix Code has a built-in, online IDE and backend so you can just add the code you need to your page or your site, publish, and you’re live."

So, I thought they have a backend IDE where I can write backend code directly, or I could call my Java program. But, as I tried doing this and finding tutorials, it seems I can really only do this by calling a public API from the backend...?

https://youtu.be/tuu0D1izrUU

But ive also read (and someone who supposedly has done it before told me this) that Wix integrates with node.js, which is a backend version of JavaScript.

Can I use a Wix domain for a NodeJS app?

But, when I go into my Wix site I cannot find any option for using Node JS, and doing research on that gives me no useful results.

So, I'm thoroughly confused on what the capabilities are here. Can someone help me make sense of this?

Why are there no tutorials showing explicit code in the Corvid backend module? What's stopping me from simply writing my Java program there in a module? Do I really need an API endpoint to call and pass to the front end?

Is Node JS supported or not - has anyone done this before?

Also, in one link above they said everything is "serverless". But if I have to set up my own API endpoint won't I need to set up my own server??


Solution

  • There are basically two ways to go about this, which you seem to have already discovered.

    1. Write your backend code in your Wix site. Indeed, the backend is built on Node.js as you can see here. Using this approach you will have to use JavaScript. As you seem to have found, you write this code in the Backend section of your site in a Web Module. Pros: you don't need to worry about managing a server and all your code is in one place.
    2. Expose your already existing Java code as an API that your Wix site can call using the wix-fetch API. Pros: you don't need to rewrite your code.