# @srejs/common

> Srejs是一个轻量级服务端渲染骨架工具，为koa社区的nodejs开发框架提供具有服务端渲染能力的工具包，使得类似umajs类的web开发框架可以更方便实现前后端同构的服务端渲染能力。特点：轻量级，模板式调用页面进行服务端渲染，不限制后端路由。

Latest version **1.4.0** (published 2024-04-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @srejs/common
pnpm add @srejs/common
yarn add @srejs/common
bun add @srejs/common
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.4.0 |
| Published | 2024-04-28 |
| First published | 2021-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 25.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bubblem, dazjean |
| Keywords | ssr, react, @umajs/plugin-react-ssr, umajs-react-ssr, @srejs |

## Links

- npm: https://www.npmjs.com/package/@srejs/common
- Repository: https://github.com/dazjean/srejs
- Homepage: https://github.com/dazjean/srejs#readme
- Issues: https://github.com/dazjean/srejs/issues
- npm.io page: https://npm.io/package/@srejs/common

## Dependencies (7)

- [ora](https://npm.io/package/ora.md) ^5.4.1
- [react](https://npm.io/package/react.md) ^17.0.2
- [koa-send](https://npm.io/package/koa-send.md) ^5.0.0
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [react-router-dom](https://npm.io/package/react-router-dom.md) ^5.2.0
- [koa-webpack-middleware](https://npm.io/package/koa-webpack-middleware.md) ^1.0.7
- [webpack-hot-middleware](https://npm.io/package/webpack-hot-middleware.md) ^2.25.0

## Recent versions

- 1.4.0 (latest) — 2024-04-28
- 1.3.10 — 2023-08-15
- 1.3.2 — 2021-12-08
- 1.3.1 — 2021-11-30
- 1.3.0 — 2021-11-22
- 1.2.8 — 2021-09-26
- 1.2.7 — 2021-09-24
- 1.2.4 — 2021-09-07
- 1.2.3 — 2021-08-27
- 1.2.2 — 2021-08-06
- 1.0.1 — 2021-08-03
- 1.0.0 — 2021-07-30
- 1.0.0-alpha.0 — 2021-07-13

## README

<div align="center">
  <img src="./doc/Srejs.png" width="300" />
</div>
<br />

<div align="center">
  <strong>Server rendering engine, abbreviated as srejs, is the server-side rendering engine. It provides the simplest and most flexible react and Vue lightweight server-side rendering skeleton tool for each node development framework, and supports the use in any koa framework.</strong>
</div>
<br />
<div align="center">
<a href="https://npmcharts.com/compare/@srejs/react" target="_blank"><img src="https://img.shields.io/npm/dt/@srejs/react" alt="react"></a>
<a href="https://npmcharts.com/compare/@srejs/react" target="_blank"><img src="https://img.shields.io/npm/dt/@srejs/vue" alt="vue"></a>
<a href="https://github.com/dazjean/Srejs" target="_blank"><img src="https://img.shields.io/npm/l/vue.svg" alt="License"></a>
<a href="https://github.com/dazjean/Srejs" target="_blank"><img src="https://img.shields.io/badge/node-%3E=10-green.svg" alt="Node"></a>
</div>
<br />

> Server rendering engine 缩写为 Srejs, 即服务器端渲染引擎，为各个node开发框架提供最简单，最灵活的React，Vue轻量级服务端渲染骨架工具，支持在任何koa框架中使用。

## Development and debugging

```shell
yarn install
## debugg React
cd packages/app && npm start  

## debugg Vue2.0 
cd packages/app-vue && npm start 

## debugg Vue3.0
cd packages/app-vue3 && npm start 
```

## Feature

- 🚀 Support SSR and CSR(支持SSR和CSR)
- 🚀 State management（redux/vuex）
- 🚀 Initialize the component props on the server side(在服务端初始化组件Props)
- 🚀 Nested Route（React-Router/Vue-Router）
- 🚀 Customize HTML and SEO
- 🚀 Support spa and mpa(单页面应用和多页面应用)
- 🚀 Support page level build updates（按需构建指定页面编译）
- 🚀 Support layout(@srejs/react支持)
- 🚀 React16+
- 🚀 Vue2.0
- 🚀 Vue3.0

## How to Use

### Develop page components（React/Vue）

```ts
//web/pages/index/index.ts
import React from 'react'
export default function (props:any) {
  const { title } = props
  return <div className="ts-demo">{title}</div>
}
```

### Use in koa Middleware

```js
import koa from 'koa';
import srejs from '@srejs/react';
// import srejs from '@srejs/vue'; 

const app = new koa();
const Sre = new srejs(app，process.env.NODE_ENV != 'production',false); 
app.use((ctx,next)=>{
    Sre.render(ctx,'index',{title:'The page title'})
})
app.listen(8001);
```

### Production

Page components need to be compiled in advance before deployment in the production environment

Add `scripts` configuration to the `package.json`

```shell
"scripts": {
    "build":"npx ssr build",
    "analyzer": "npx ssr analyzer",
},
```

## Quick start

- [React](https://github.com/dazjean/Srejs/tree/main/packages/react)
- [Vue2.0](https://github.com/dazjean/Srejs/tree/main/packages/vue)
- [Vue3.0](https://github.com/dazjean/Srejs/tree/main/packages/vue3)

## Questions

Please open an [issue](https://github.com/dazjean/Srejs/issues/new/choose)

## License

[MIT License](./LICENSE)

Copyright (c) 2021 dazjean

---
_Source: https://npm.io/package/@srejs/common · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
