I Built The Same Full-Stack App With Deno and Node. This Is What I Learned So Far…

Yash Garudkar
The Startup
Published in
4 min readJun 29, 2020

--

There’s a big buzz out there regarding which back-end technology is better Node.js or Deno. So I went ahead to create the same app using both technologies.

I made a full-stack Todo app using React for front-end and used Node.js and Deno as back-end. You can either use Deno or Node.js as a standalone back-end application.

I use Node.js for my applications all the time. But using Deno for a full-stack application was new. I referred docs on Deno official website for this purpose. React is something I just started using and I am still a beginner on the learning path. I used bootstrap for styling and kept it simple.

GitHub repository at the end of the article.

Let’s take a look at how the front-end of our full-stack application looks like

I added basic functionality like adding a new task, editing a task, and marking a task as completed.

Front-end with React and Bootstrap

Now let’s see the differences I came across while building the back-end.

1. File structure

The file structure for both apps is the same except for the package.json and node_modules folder in Node.

Node.js needs a package.json file to save the information needed to run the application, the packages the needed to run the application. On running the npm install command, specified packages are saved in the node_modules folder. These packages are used in the application further.

Deno doesn’t need a modules folder because it loads the modules at runtime. it does need an internet connection for the same, unlike Node where you don’t need internet after the module has been installed by npm (node package manager). It also doesn’t need the package.json because the packages needed to run the application are imported in the files and retrieved from the online repositories at runtime.

2. TypeScript Support

Node.js does not support TypeScript out of the box. You need additional packages to do that.

Deno supports both TypeScript and JavaScript out of the box. The code I used in building the Deno back-end is also in TypeScript.

3. Accessing _id in React

For editing the existing task I needed to access _id of the task object via the params in URL.

React Component

In Node was as easy as, rendering the object _id in the URL link. In the image above you can see how I simply did the render in Node.

In Deno, the Mongo API did not give direct access to the _id I had to access the object id $oid in the _id. This might be because the library is in its early stages. You can see the same in the image above.

4. Top-level await

This is my favorite feature in Deno. Deno has a promise based await feature. We can directly use await without declaring an async function. So we can have await statements without wrapping them inside an async function.

const pizzas = await fetch('https://damnilovepizzas.com/pizzas')

5. Security and run commands

Comparing to Deno, Node.js has no default security parameters.

As per Deno’s official website, Deno is “Secure by default. No file, network, or environment access, unless explicitly enabled.”

The command needed to run a Node.js application is simple.

$ node server.js

Whereas in Deno we need to provide it multiple parameters to allow it access to the network, environment access, or files. It looks like:

$ deno run  --allow-net --allow-write --allow-read --allow-plugin --unstable server.ts

6. Support

In comparison to Node, this is very little support available on online sites like StackOverflow.

As Deno was launched recently it is too early to have a support community.

In this category Node easily wins as it has a huge support community and a lot of errors or questions that you might run into are already solved by other users.

Conclusion

It is hard to say which one is better than the other. In my opinion, both technologies are great. Deno is in its initial stages and hence a little difficult to cope up with but both technologies have a great future.

In comparison, I think both of them have different applications. It’s almost like how people compare Angular and React, but as we know they both have different use cases and advantages.

I hope this article was helpful for you to decide which technology to go for in your next project.

If you have suggestions please let me know in the comments section🙋‍♂️

Thank You!🖤

GitHub repository for this article: https://github.com/yashgkar/deno-node-react-app

Like My Work? How about buy me a coffee?😉

--

--