DEV Community

Discussion on: How can I make a visual UI in the browser for a Node application?

Collapse
 
christiankozalla profile image
Christian Kozalla

Node is a Javascript runtime, that allows you to use JS as a server-side language. So with Node you will be able to set up a web server that serves static HTML files under different routes.

You can also use that node server to set up an API for querying a database or process data dynamically on the server side before sending the HTTP response to the Frontend. Express.js is often used to set up an API on a node server. You can create a CRUD API (create, read, update, delete) for example.

It would be very helpful, if you shared some of your code and / or explain more about what you want to achieve. 👍

Collapse
 
baenencalin profile image
Calin Baenen

All I want to do is link Node (as a backend) to a frontend (any GUI toolkit).

I'm making a Discord bot to be used as a an application (separate from Discord, but serving a similar purpose to).

Collapse
 
christiankozalla profile image
Christian Kozalla

let's say you use a React frontend with your Node backend. Then your backend might have a route /messages on which you can perform a GET request from your frontend, e.g.

fetch('https://yournodebackend.com/messages)
  .then(response => response.json())
  .then(jsonResponse => console.log(jsonResponse)) // or do whatever you like
Enter fullscreen mode Exit fullscreen mode

If your node backend supports more routes and request types like POST, PUT, DELETE, you can query them from your frontend similarly.

Hope, this could go in the right direction for your purpose..! Happy hacking 😄