{"library":"socketio-jwt-auth","title":"Socket.io JWT Auth","type":"library","description":"Socket.io authentication middleware using JSON Web Tokens (JWT). Current stable version is 0.2.0. This package provides a simple way to authenticate Socket.io connections by verifying a JWT token passed as a query parameter (or auth object for Socket.io v3+). It supports custom secret, algorithm selection, and optional succeedWithoutToken mode for guest connections. The package is designed for Socket.io >= 1.0 and is commonly used to protect WebSocket endpoints. Unlike more modern alternatives like socketio-jwt (which is more actively maintained), socketio-jwt-auth has a simple API but has not seen updates since 2018.","language":"javascript","status":"maintenance","last_verified":"Sat Apr 25","install":{"commands":["npm install socketio-jwt-auth"],"cli":null},"imports":["const jwtAuth = require('socketio-jwt-auth');","const { authenticate } = require('socketio-jwt-auth');","io.use(jwtAuth.authenticate(options, verify));"],"auth":{"required":false,"env_vars":[]},"links":{"homepage":null,"github":"https://github.com/adcentury/socketio-jwt-auth","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/socketio-jwt-auth","openapi_spec":null,"status_page":null,"smithery":null},"quickstart":{"code":"const io = require('socket.io')(3000);\nconst jwtAuth = require('socketio-jwt-auth');\n\n// Simple middleware that accepts token and attaches user info\nio.use(jwtAuth.authenticate({\n  secret: 'mySecret',\n  algorithm: 'HS256'\n}, (payload, done) => {\n  // Simulate user lookup\n  const user = { id: payload.sub, name: 'John Doe' };\n  done(null, user);\n}));\n\nio.on('connection', (socket) => {\n  console.log('User authenticated:', socket.request.user);\n  socket.emit('authenticated', { message: 'Welcome!' });\n});\n\n// Client connects with token\nconst socket = require('socket.io-client')('http://localhost:3000', {\n  query: 'auth_token=validJWTToken'\n});","lang":"javascript","description":"Shows how to set up Socket.io server with JWT authentication middleware and client connection with token.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}