/henri

henri is a simple way to start using Feathers and Next.js

Primary LanguageJavaScriptOtherNOASSERTION

henri = Feathers + Next.js

NPM

Version tag bitHound Dependencies

henri is a simple way to start using Feathers and Next.js

How to use

To install:

  npm install henri --save

Full example

A fully fonctionnal application can be found here: https://github.com/simplehub/henri-full-example

Basic setup

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();

Plans

  • Add a generator

Thanks to the following and their contributors