An open API service indexing awesome lists of open source software.

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

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