I have successfully followed the https://hub.safedev.org/platform/web/ example. My understanding is that node.js is only required for development and in ‘production’ all that is left is static/clientside code. Is that correct? If not, how will/can nodejs be hosted on a distributed platform?
I shared this confusion, but NodeJS is not just server side. It has been adapted so that now it can be used in the client (see browserify, but that is no longer the only route).
So these example apps using nodejs work fine without a server on SAFE Network.
TL;DR: The solution above is not quite accurate. In production, Node is not used or required during any step in the process.
Node can be used in development to help you compile and serve your code for viewing on
Once you compile your code for production, as you mentioned, all you’re left with is static HTML + CSS + JS files. Those static files are hosted by computers on the SAFE Network, and when you visit a SAFE website, your browser reads those static files and displays the website.
In production, Node is not used or required during any step in the process. It was simply used to compile the code when you originally published the website.
@cooperka, i don’t think this is correct:
From the article you linked:
From what i understand the difference is that some code is purely browser clientside js (f.e. alert) and some node serverside (f.e. http server)
From Node’s homepage:
Does that help clarify?
The code itself is not browser vs. server; it’s a matter of what facilities are available in the execution environment. Most terminals don’t provide an
alert function, so Node will crash if you try to call
alert because it simply doesn’t exist. Most browsers, however, provide that function so it will work.
For fun, you can use a library such as alert-node to get
alert in Node.
Similarly, running an HTTP server isn’t feasible from inside a browser. The code is perfectly valid, but the browser doesn’t provide the required facilities. Those are only available in the terminal via Node.