Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

146
Views
Append child to html before sending to the client in SSR App

Actually I am using node js to implement SSR in my app.In server side rendering, html is prepared inside the server dynamically and updated.I want to update my html root element in the server using a js file but before sending it to the client. but when i tried it the js file is executing in the client. i want to execute it in the server and then append child to the html and then send that html file. Anyone help if it a wrong method and if not how can i do it

//my app.js
const express = require('express');
const app = express();
const path= require('path');
const cors = require('cors');

// const {sourceHTML} =require('./middlewares/fileHandler');

//for rendering css through the server we use app.use()
app.use(express.static(__dirname));
app.use(cors());



app.listen(3000,()=>{
    console.log("application started and running on port 3000")
});
app.get("/",(req,res)=>{
    res.status(200).sendFile(__dirname+'/html/home.html')
})

my home.html

  <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>home</title>
    </head>
    <body>
        <div id="root"></div>
    </body>
    </html>

so basically i want to edit html file from a js file so to access that html i have to use script tag inside html but problem happens that the script tag is parsed to the client so actually i want to execute that script at the server side before sending.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!