Clarification on instructions for backend Code in Wix
Asked Answered
F

1

6

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??

Fellowship answered 26/5, 2019 at 15:15 Comment(0)
I
5

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.
Iverson answered 27/5, 2019 at 5:55 Comment(3)
Hi Sam, thank you for the response! I know how to create a backend module with .jsw extension. Is that the Node JS file? I didn't think it was because I know Wix has their own hybrid of language (referencing $w objects for example). And, if I were to take case 2 from your response...I would need to set up my own web server to do that (I know there are some services like AWS to help, but it takes extra steps), to build my own API which I could call using Wix fetch. Is this all correct?Fellowship
@Fellowship it sounds like you have the correct understanding of how it all works. I would say option 1 is preferred where possible. Also, I wouldn't say $w is a hybrid language. It is all JavaScript. You can think of it as another JS library - something akin to JQuery.Iverson
Sam, Ok - if the things I said are accurate, then I also feel that I understand now. It was helpful for me to write down/organize why I was confused and have someone else confirm my suspicions after so many days of research. I did not realize that the .jsw module was Node.JS. I still don't understand why I found so few online examples, tutorials or forums addressing these different parts. I suppose WIX isn't that popular for developers since it's supposedly not as flexible as other platforms...although it seems like a good option to me...at least I feel that I can move forward now. THANK YOU!Fellowship

© 2022 - 2024 — McMap. All rights reserved.