Last active
July 20, 2017 16:20
-
-
Save OutThisLife/741b4035e54e9216dc049442eea6bc38 to your computer and use it in GitHub Desktop.
SSR react
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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