Realtime
Reference doc for the `sst.aws.Realtime` component.
The Realtime
component lets you publish and subscribe to messages in realtime.
- It offers a topic-based messaging network using AWS IoT.
- Lets you publish and subscribe to messages using WebSocket in the browser and from your server.
- Provides an SDK to authorize clients, and grants permissions to subscribe and publish to topics.
Use realtime endpoint in your app
Use the RealtimeAuthHandler
function in the SDK to authorize
the client, and grant permissions to subscribe and publish to topics.
Publish and receive messages in your frontend
Subscribe messages in your backend
Publish message from your backend
Constructor
Parameters
-
name
string
-
args
RealtimeArgs
-
opts?
ComponentResourceOptions
RealtimeArgs
authorizer
Type Input
<
string
|
FunctionArgs
>
The Lambda function that’ll be used to authorize the client on connection.
transform?
Type Object
Transform how this subscription creates its underlying resources.
transform.authorizer?
Type AuthorizerArgs
|
(
args
:
AuthorizerArgs
=>
void
)
Transform the IoT authorizer resource.
Properties
authorizer
Type Output
<
string
>
The name of the IoT authorizer.
endpoint
Type Output
<
string
>
The IoT endpoint.
nodes
Type Object
The underlying resources this component creates.
nodes.authHandler
Type Output
<
Function
>
The IoT authorizer function resource.
nodes.authorizer
Type Authorizer
The IoT authorizer resource.
SDK
The following are accessible through the SDK at runtime.
Links
The name of the IoT authorizer.authorizer
string
The IoT endpoint.endpoint
string
RealtimeAuthHandler
Parameters
-
input
(token:
string
) =>Promise
<
RealtimeAuthResult
>
Returns IoTCustomAuthorizerHandler
Creates an authorization handler for the Realtime
component, that validates
the token and grants permissions for the topics the client can subscribe and publish to.
RealtimeAuthResult
Type Object
RealtimeAuthResult.publish?
Type string
[]
The topics the client can publish to.
For example, this publishes to specific topics.
And to publish to all topics under a specific prefix.
RealtimeAuthResult.subscribe?
Type string
[]
The topics the client can subscribe to.
For example, this subscribes to specific topics.
And to subscribe to all topics under a specific prefix.
Methods
subscribe
Parameters
The function that’ll be notified.subscriber
string
|
FunctionArgs
- Configure the subscription.
Returns Output
<
RealtimeLambdaSubscriber
>
Subscribe to this Realtime server.
Customize the subscriber function.
RealtimeSubscriberArgs
filter
Type Input
<
string
>
Filter the topics that’ll be processed by the subscriber.
Subscribe to a specific topic.
Subscribe to all topics under a prefix.
transform?
Type Object
Transform how this subscription creates its underlying resources.
transform.topicRule?
Type TopicRuleArgs
|
(
args
:
TopicRuleArgs
=>
void
)
Transform the IoT topic rule resource.