无需配置即可创建React服务器端工具。
npx create-kkt-app my-app cd my-app npm start
您还可以从其中一个示例初始化项目。 例如kktjs/kkt-ssr。
# Using the template method # `npx create-kkt-app my-app [-e example name]` npx create-kkt-app my-app -e react-router+rematch
or
npm install -g create-kkt-app # 创建项目,使用模板方法 create-kkt-app my-app -e react-router+rematch cd my-app # 输入my-app目录 npm start # 开始服务
开发
以开发模式运行项目。
npm run start
生产环境
将生产应用程序,构建到构建文件夹。
npm run build
构建被缩小,文件名包含哈希。 您的应用已准备好部署!
# 在生产中运行已编译的应用程序。 npm run server
对于生产项目,建议使用完整的 react + react-router + rematch(redux) 示例,类似于 next.js.
react + react-router + rematch(redux)
basic - Server-side rendering of the react base application.
basic
dynamic-loadable - A react-loadable for server side rendering for your react application.
dynamic-loadable
less - React uses the server side rendering of the Less based application.
less
mock-api - Server-side rendering mock api of the React base application.
mock-api
reach-router + loadable-components - A reach-router loadable for server side rendering for your react application.
reach-router + loadable-components
react-router - React uses server-side rendering of the react-router.
react-router
react-router + loadable-components - A react-router loadable-components for server side rendering.
react-router + loadable-components
react-router + rematch + loadable-component - A react-router loadable-components for server side rendering.
react-router + rematch + loadable-component
react-router+rematch - This is a sophisticated example, similar to next.js.
react-router+rematch
scss - React uses the server side rendering of the sass based application.
scss
styled-components - Server-side rendering of the react styled-components base application.
styled-components
stylus - React uses the server side rendering of the stylus based application.
stylus
unstated - React uses the server side rendering of the unstated based application.
unstated