r/javascript • u/wasitshafi • 6d ago
Template engine EJS vs Eta for a new Node.js project with SSR(don't want to use NextJS), which to choose?
https://npm-compare.com/ejs,eta/#timeRange=ALLHi,
I am about to start a new project with SSR (Node.js); previously, I have used ejs/handlebars. Currently, I am not very familiar much eta.
eta claims to be faster than ejs, anyone worked with both?
Highly appreciate your suggestions/comments.
ejs: https://www.npmjs.com/package/ejs
eta: https://www.npmjs.com/package/eta
Thanks
3
u/kevinkace 5d ago
I used ejs on many projects and then used Eta on a new one, tbh I can't recall what led to my decision, but I also can't recall having any regrets and was happy with the decision.
3
u/Evgenii_Korolev 4d ago
speed won't really be the deciding factor, both compile templates and can cache them, and on a real SSR page your db calls will take way longer than the render. i'd pick eta for a new project mainly because it has layouts built in, with ejs you end up stitching header/footer includes into every page or pulling in express-ejs-layouts. it's also written in TS so the types are decent. two things that trip people up coming from ejs: data lives on it, and unescaped output is <%~ not <%-.
<% layout('./base') %>
<h1><%= it.title %></h1>and in base.eta you print the page with <%~ it.body %>.
1
u/Ronin-s_Spirit 5d ago
You could always write your own, it can be very easy depending on what you wanna do.
1
u/PermissionOwn4400 1d ago
Have you considered Hono with Jxs? It works fine with node and provides very good DX.
•
u/Senior-Assumption864 6h ago
agreed, for ssr the render speed rarely matters, so id pick whichever one feels nicer to work with
1
u/lanerdofchristian 5d ago
Is it specifically NextJS you're avoiding, or full-stack frameworks in general including SvelteKit, Nuxt, and Astro?