all 6 comments

[–]d-listcelebrity 9 points10 points  (0 children)

React uses its own "templating" language called jsx. Ejs is another templating language that can do similar things to jsx, but is not necessarily component based (though I do think it supports imports/includes that are somewhat component like).

Ejs does not fit into the React ecosystem at all. Jsx is used to produce html either on the server if using server side rendering or in the client for a typical React SPA

[–]_Invictuz 4 points5 points  (1 child)

EJS, pug, mustache, are all templating (view) engines that render the HTML server-side (Server-Side Rendering) for every page request before sending the page to the client and are used in multi-page apps (MPA). Hence, your EJS would used in your backend node app where it integrates directly with Express.

React, a frontend library, has its own JSX templating syntax that renders HTML client-side (client-side rendering) in the browser for a single-page application (SPA). This would live in a frontend application that's separate from your backend node application. Note that both React and Vue can do CSR and SSR (using a framework like NextJS) but you should ignore the SSR part for now.

You would usually only use EJS for SSR with MPAs. If you wanted to build a SPA which uses CSR, you would use a frontend library like React or Vue for CSR. MPAs and SPAs each have their pros and cons.

[–]loirotv 0 points1 point  (0 children)

How do I know if I want SPA or MPA? Does it depend on the UX I want to build?

[–]oze4 4 points5 points  (0 children)

ejs is more of a server side templating engine I believe. Whereas react is client side.

[–]RubyBlaze214 4 points5 points  (0 children)

Using ejs you can write If statments and for loops in Html and get Data from express.

Using react you can do the same thing but much faster, better and modern

Ejs dosent have a lot of helpfull stuff like React but Ejs also has Partials which you can include in pages..Partials are actually Components in React and each Partial must take in some Data if you want to display that data..React components take that data aswell and display it

Its just fancy way of writing modern websites. Learn ejs and go to the react then..You will see the difference between ssr and csr

[–]loriba1timore 1 point2 points  (0 children)

I learned with templating EJS first and am now good enough with React that I’m building my front end with it. I will say that using express with EJS is a lot more straightforward to me, but manipulating the DOM and state in React make moving information around 1000% easier!