henri is a simple way to start using Feathers and Next.js
To install:
npm install henri --save
A fully fonctionnal application can be found here: https://github.com/simplehub/henri-full-example
Create a default config in config/default.json
containing Feathers configs:
{
"host": "localhost",
"port": 3030,
"nedb": "../data/",
"next": "../client/",
"auth": {
"secret": "some-secret",
"local": {},
"cookie": {
"enabled": true
}
}
}
With the above config, your directory structure should look like this:
├── client/
│ ├── pages
│ │ ├── index.js
│ │ ├── a.js
│ │ ├── b.js
│ ├── static
│ │ ├── favicon.ico
│ │ ├── some.css
├── config/
│ ├── default.json
├── node_modules/
├── public/
├── src/
│ ├── index.js
├── package.json
And finally, add this to your src/index.js
and you're ready to go:
const henri = require('henri');
// Feathers app (express-like)
const app = henri.init();
// The Next.js renderer
const view = app.view;
// You should register your service right here / add connectors
// Next.js
app.get('/', (req, res) => {
return view.render(req, res, '/index');
});
app.get('/a', (req, res) => {
return view.render(req, res, '/a');
});
app.get('/b', (req, res) => {
// Allow from multiple origin (Access-Control-Allow-Origin=*)
res.forceCORS = true;
return view.render(req, res, '/a');
});
// express routes
app.get('/hello', (req, res) => {
return res.render('Hello, Henri!');
});
henri.run();
- Add a generator