• Experimental

    API may change in future versions

    Establish a WebSocket connection to an Events channel

    Parameters

    • channel: string

      channel path; <namespace>/<channel>

    • Optional options: EventsOptions

      request overrides: authMode, authToken

    Returns Promise<EventsChannel>

    Example

    const channel = await events.connect("default/channel")

    channel.subscribe({
    next: (data) => { console.log(data) },
    error: (err) => { console.error(err) },
    })

    Example

    // authMode override
    const channel = await events.connect("default/channel", { authMode: "userPool" })