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

123
Views
Render React ES6 to String for Express

I've coded an React Application in ES6 style, all my Components are build like the following:

import React, { Component } from 'react';

class Test extends Component {
    render() {
        return (
            <div className="testDiv">
                Hello Word
            </div>
        )
    }
}

export default Test;

This website is running via the default configuration via "npm start" at port 3000.

Furthermore I've an nodeJS application with an API via expressJS on port 8080. Now I want to create an single route to express where I can render the React application and deliver the HTML String back to the client. What's the best way to do this ? I'm new to React development, hope somebody can help.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Here's a minimalistic example how to render your Test component on an Express server:

import express from 'express';
import Test from './Test';
import React from 'react';
import ReactDOM from 'react-dom/server';

const app = express();

app.get('*', (req, res) => res.send(ReactDOM.renderToString(<Test />)));

app.listen(8080);
about 4 years ago · Santiago Trujillo Report
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!