fastify-socket.io
enables the use of Socket.io in a Fastify application.
Supports Fastify versions 3.x
npm i fastify-socket.io
Require fastify-socket.io
and register it as any other plugin, it will add a io
decorator.
const fastify = require('fastify')()
fastify.register(require('fastify-socket.io'), {
// put your options here
})
fastify.get('/', (req, reply) => {
fastify.io.emit('hello')
})
fastify.listen(3000)
For more details see examples
You can use it as is without passing any option, or you can configure it as explained by Socket.io doc.
The code is a port for Fastify of socket.io
.
Licensed under MIT.
socket.io
license