简体   繁体   中英

React Server Side Rendering with webpack?

Is there a way to create a react app with server side rendering without using express js as server or Next.js for example?

Can I just use webpack to do server side rendering?

You must have express or any language http server setup to host your files if you ever want to have this app live regardless if you want to have SSR or not.

https://survivejs.com/webpack/output/server-side-rendering/

This guide should help you out with webpack and express

如果您确实需要在 webpack 构建期间从 react 中静态渲染文件,请查看此插件: https : //github.com/thread/react-static-render-plugin/

In production, the JS output for SSR needs to be required by node with expressjs or other web frameworks. Or you can use FaaS(Azure Function, AWS Lambda) to require that JS output to perform SSR

In development, you can have a try this webpack plugin . It reuses webpack-dev-server response dynamic html based on request parameter

It has two examples from simple react app to advanced react-relay app

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM