Using with Adonis

Adonis has gained traction since its launch, and I have received a couple of requests on how to integrate with Adonis.

Check out adonis official docs

I am working v2 that will have 1st class support for

Here I will explain the simplest way to use with Adonis.


npm install --save  


Setting up

With installed, you have to create a file inside app/Http/ folder called socket.js and put following into it.


const server = use('http').createServer()  
const io = use('')(server)  
io.on('connection', function (socket) {  
    console.log('connection created >>>')

Now we have created the socket.js file but we need to load it while booting our server.


After use('App/Http/routes') include our newly created socket.js file.

|   Loading File
|   Here we register socket.js file to work with



From here you can follow the normal process to setup on the client end.

Go to and search for

Place following inside your resources/views/partials/master.html file.

  <script src=""></script>
  var socket = io('http://localhost:3000');


Start Server

npm start  

Bingo! , that's all you need to setup in your Adonis app.

I agree this is not the best way to do it, but until v2.0 this may be the simplest way to do it.