zhangyuang / egg-react-ssr

最小而美的Egg + React + SSR 服务端渲染应用骨架,同时支持JS和TS
http://doc.ssr-fc.com/
MIT License
1.91k stars 212 forks source link

add koa/express support #99

Open i5ting opened 5 years ago

i5ting commented 5 years ago

example

const conf = require('./config/config.ssr')
const ssr = require('egg-react-ssr').koa(conf);

const Koa = require('koa');
const app = new Koa();

//  mount routes from config
app.use(ssr)

// ctx.ssrRender()
app.use(async ctx => {
  ctx.ssrRender(...);
});

app.listen(3000);
i5ting commented 5 years ago

上面的方案,解决了product问题

单还存在一个dev时候的问题

这个有更好的解法么?

i5ting commented 5 years ago
app.use(ssr.dev())
JohannLai commented 5 years ago

这个方案做得很好很认真,期待支持 koa ~ 💯