Beginner guide NodeJS
Hi, i'm looking for someone to guide me a bit into NodeJS
14 Replies
have you tried looking on youtube for tutorials, or searched for written getting started guides?
yeah, but im kinda in a loop and have no idea what's happening
someone with hands on will clarify it for me in short, i'll understand it better
where is it used, how is it used, when should u write node code
node is for code run on the backend, so server-side, or for local CLI tools
if you have things that require either of those, you'd use node
could you please give me an example when should i use it? like a real world scenario, for which project case
the most basic one would be a backend for a todo app. The API you'd call to authenticate and authorize your users, and store their todo items in the database
aha, so that's like going without services that does authentication (libraries) etc, doing it on your own
did i understood it correctly?
You can use services to authenticate still, and there's frameworks and libraries for backend code too
maybe auth muddles the example, so just focus on the API to fetch, edit, and store the todo items for a todo app
in short its used to build API's the most cases?
generally, yeah
that's most of backend code, really
though there's more full-fat frameworks too. You can use it to generate HTML to serve to the user, just like you would with PHP (with or without Laravel or some other PHP framework / templating language)
I have no hands on experience with the backend and that's why i am a bit confused, trying to understand it.
i generally write react/nextjs code, just the frontend
with ready to use api's, just fetching them
and i've seen tutorials that you can also generate HTML with NodeJS, that confused me as well
when should you use that? are there cases where you'd do that?
it's a choice, really... Sometimes, you can't use static HTML, or you don't want to use React because it's got a lot of overhead on the client side. Sometimes you don't want an open API to give access to your data, and you just want to render variable data server side. Some people just prefer to render their data server side, or it improves caching, or a thousand other concerns that might make it easier to use server side rendering
it's faster on the client, most of the time, even if it's slightly higher load on the server
what should i remember it as a beginner and aim to learn more? just to build API's with it in the most cases right?
that's pretty much it, yeah, especially if you're using React. Though if you're using React, stuff like NextJS also runs in Node afaik
and usually you'd build the backend for a React app in Next if you have free choice anyway
okay thank you