Skip to content

Instantly share code, notes, and snippets.

@OutThisLife
Last active July 20, 2017 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OutThisLife/741b4035e54e9216dc049442eea6bc38 to your computer and use it in GitHub Desktop.
Save OutThisLife/741b4035e54e9216dc049442eea6bc38 to your computer and use it in GitHub Desktop.
SSR react
import React from 'react'
import { renderToString } from 'react-dom/server'
import express from 'express'
import Homepage from './src/pages/home'
const
port = process.env.PORT || 3000,
app = express()
// -----------------------------------------------
app.get('/', (req, res) => {
return res.send(renderToString(<Homepage />))
})
// -----------------------------------------------
app.listen(port, () => console.log('Listening on port', port))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment