Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

122
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda