{"library":"matter-server","title":"Matter.js WebSocket Server","description":"The `matter-server` package implements a comprehensive Matter Controller Server over WebSockets, leveraging the JavaScript Matter SDK `matter.js` as its foundational layer. It currently stands at stable version `0.6.1`, with a development cadence that includes frequent nightly alpha releases alongside regular official updates, indicating active and continuous development. This project differentiates itself by providing a full-fledged web server, a WebSocket endpoint that adheres to the Open Home Foundation (OHF) Matter Server API (with logic encapsulated in `@matter-server/ws-controller`), and an interactive dashboard (powered by `@matter-server/dashboard`). It also integrates community-provided custom Matter clusters via `@matter-server/custom-clusters` and ensures backward compatibility with the OHF Python Matter Server, facilitating migration and interoperability for existing users. Client applications can connect using the companion `@matter-server/ws-client` library. The server is designed for modern Node.js environments, specifically requiring Node.js versions `>=20.19.0 <22.0.0` or `>=22.13.0`.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install matter-server"],"cli":{"name":"matter-server","version":null}},"imports":["import { MatterServer } from 'matter-server';","import { MatterServer, type MatterServerOptions } from 'matter-server';","import { Logger } from '@project-chip/matter-node.js/log';"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { MatterServer, MatterServerOptions } from 'matter-server';\nimport { Logger } from '@project-chip/matter-node.js/log';\n\nconst MATTER_PORT = parseInt(process.env.MATTER_PORT ?? '5580', 10);\nconst MATTER_SERVER_ADDRESS = process.env.MATTER_SERVER_ADDRESS ?? '0.0.0.0';\nconst MATTER_FRONTEND_PATH = process.env.MATTER_FRONTEND_PATH ?? undefined;\n\nasync function startMatterServer() {\n  const logger = new Logger('MatterServerQuickstart');\n\n  const serverOptions: MatterServerOptions = {\n    port: MATTER_PORT,\n    host: MATTER_SERVER_ADDRESS,\n    frontendPath: MATTER_FRONTEND_PATH,\n    // Optionally configure Matter.js backend settings here\n    // For example, persistent storage paths, device setup, etc.\n  };\n\n  const server = new MatterServer(serverOptions);\n\n  try {\n    logger.info(`Starting Matter WebSocket Server on ${MATTER_SERVER_ADDRESS}:${MATTER_PORT}...`);\n    await server.start();\n    logger.info(`Matter WebSocket Server started successfully.`);\n    if (!MATTER_FRONTEND_PATH) {\n        logger.info(`Dashboard available at http://localhost:${MATTER_PORT}`);\n    }\n    logger.info(`WebSocket endpoint: ws://localhost:${MATTER_PORT}`);\n\n    // Keep the server running until explicitly stopped\n    process.on('SIGINT', async () => {\n      logger.info('Shutting down Matter WebSocket Server...');\n      await server.close();\n      logger.info('Matter WebSocket Server stopped.');\n      process.exit(0);\n    });\n\n  } catch (error) {\n    logger.error(`Failed to start Matter WebSocket Server: ${error}`);\n    process.exit(1);\n  }\n}\n\nstartMatterServer();\n","lang":"typescript","description":"This quickstart initializes and starts the `matter-server` on a specified port, demonstrating basic setup and graceful shutdown for a WebSocket Matter controller.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}