Skip to content

Instantly share code, notes, and snippets.

@chuck0523

chuck0523/server.js

Created Jun 13, 2016
Embed
What would you like to do?
import express from 'express'
import React from 'react'
import ReactDOMServer from 'react-dom/server'
import Counter from './components/Counter'
const app = express()
app.use(express.static('public'))
app.get('/', (req, res) => {
res.send(
ReactDOMServer.renderToString(
<div>
<div id="app">
<Counter />
</div>
<script src="client.js" />
</div>
)
)
})
app.listen(3000, () => {
console.log('Example app listening on port 3000!')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment