A utility library for posting messages to a connected WebSocket client via AWS API Gateway. Version 0.1.21 is the current stable release; the package is infrequently updated. It simplifies sending messages to WebSocket connections from AWS Lambda functions by wrapping the AWS SDK's ApiGatewayManagementApi. Key differentiators include support for the same gateway, another gateway, and local WebSocket servers, making it useful for development and testing.
npm install aws-post-to-connectionNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a post function from event context and sends a message to the current WebSocket connection.
Ensure options for PostToConnection include stage and domainName if not using event from same gateway.
Always use await or handle the promise to avoid unhandled rejections.
Set secure: false in options when posting to localhost without HTTPS.
Provide options object with at least stage and domainName or pass the event object.
Ensure second argument to the returned function is a valid connection ID string.
Use const PostToConnection = require('aws-post-to-connection') and then call PostToConnection(options) which returns a function.