Important: This is the documentation for a previous version of Feathers.
For the latest documentation please visit

A Feathers WebSocket Client

We already have a Feathers REST frontend. Its simple to convert that to one using WebSockets.

WebSockets. Feathers can use eight of the most popular WebSocket libraries. We will use the popular in this guide.

Working example

Change the server to support clients using either Feathers REST or WebSocket calls

Add 2 lines to the server code so it supports either REST or WebSocket calls from the Feathers client.

const rest = require('feathers-rest');
const socketio = require('feathers-socketio'); // new

const app = expressServerConfig()
  .configure(socketio()) // new

Changing the HTML for Feathers client WebSocket calls

We replace the REST code we had in the HTML with the equivalent WebSocket code.

<script type="text/javascript" src=""></script>
<script src="^2.0.0/dist/feathers.js"></script>
<script src="/"></script>
<script src="/serverUrl.js"></script>
  const socket = io(serverUrl);
  const feathersClient = feathers()
<script src="/feathers-app.js"></script>
  • See what changed: Unified | Split
  • src="/" load the client code.
  • const socket = io(serverUrl); create a WebSocket.
  • .configure(feathers.socketio(socket)) configure Feathers client to use the WebSocket.

Changing the frontend code

We've already said that most of the Feathers frontend doesn't care if it's communicating with the server using REST or WebSockets. No more changes are necessary.

REST vs WebSockets. There is a huge technical difference involved in communicating via REST or WebSockets. Feathers hides this so you can get on with what's important rather than handling such details.


And that's all there is to it. The results are identical to that for A Feathers REST Client

Is anything wrong, unclear, missing?

Leave a comment.

results matching ""

    No results matching ""