This is a setup about how to use feathers
along with next.js
.
The feathers
part are based on the code generated from the feathers-cli
. Which I think should make people understand more easily(because I consider this as the official way).
client
: next.js
part;server
: feathers
part;Including some optimizing and request handling tips.
Normally, you just use npm run server:dev
, then you can work on the server and client at the same time. It will run feathers.js
. But any changes you made in the ./client/
part will be hot reloaded and reflect to the actual page.
If you only want to work on the client side, just call npm run client:dev
npm run client:build
: To bundle the production ready code.npm run server:start:prod
: To start the server. (You might want to use PM2
or nodemon
here.)feathers
server: npm run server:dev
http://localhost:3030
, see next
pagehttp://localhost:3030/users
, see feathers.js
error page./client/pages/index.js
, see the hot module reloadingEvery time you add a feathers service
, make sure to add it to feathersServices
in ./server/middleware/next.js
like this:
const feathersServices = {
'/users': true,
};
See detail step by step in my blog