r/javascript • u/wasitshafi • 1d 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
4
Upvotes
•
u/lanerdofchristian 18h ago
Is it specifically NextJS you're avoiding, or full-stack frameworks in general including SvelteKit, Nuxt, and Astro?
3
u/kevinkace 1d 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.
•
u/Ronin-s_Spirit 15h ago
You could always write your own, it can be very easy depending on what you wanna do.
•
u/-jeasx- 9h ago
Have a look the Jeasx:
https://www.jeasx.dev
Server rendered JSX on top of Fastify. The expo shows what can be done with Jeasx:
https://expo.jeasx.dev/
If you want to roll your own solution with SSR and JSX, you can also use the underlying library on its own:
https://www.npmjs.com/package/jsx-async-runtime
•
u/Evgenii_Korolev 1h 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<%-.and in base.eta you print the page with
<%~ it.body %>.