https://github.com/djyde/hapi-plugin-ssr
React Server-Side Rendering plugin for Hapi
https://github.com/djyde/hapi-plugin-ssr
hapi hapi-plugin react ssr
Last synced: 5 months ago
JSON representation
React Server-Side Rendering plugin for Hapi
- Host: GitHub
- URL: https://github.com/djyde/hapi-plugin-ssr
- Owner: djyde
- Created: 2020-11-01T13:36:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-01T13:39:54.000Z (over 5 years ago)
- Last Synced: 2024-12-31T10:31:13.291Z (about 1 year ago)
- Topics: hapi, hapi-plugin, react, ssr
- Language: TypeScript
- Homepage:
- Size: 42 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# hapi-plugin-ssr
[WIP] React Server-side rendering plugin for Hapi.
## Usage
```bash
- pages
- home.js
- server.js
```
```js
// server.js
const hapi = require('@hapi/hapi')
const server = Hapi.server({
port: 3000
})
await server.register({
plugin: require('hapi-plugin-ssr').default,
options: {
routes: [{
path: '/',
component: './pages/home'
}]
}
})
await server.start()
```
```js
// pages/home.js
import React from 'react'
export default () => {
const [count, setCount] = React.useState(0)
return (
{count}
setCount(count => count+1)}>+
setCount(count => count-1)}> -
)
}
```
```bash
node server.js # http://localhost:3000
```
# License
MIT License