Quickstart

Connect an application to its first live data source on the Real-Time Web.

This walkthrough connects a small application to a live source, subscribes to it over a bi-link, and reacts to changes. It assumes you have access to a Morph Space workspace.

1. Get a workspace address

Every workspace has a root now-URI:

now://yourorg.morph.space/

Everything you publish or subscribe to lives under that root.

2. Resolve a source

Resolving a now-URI returns a bi-link handle. In pseudocode:

const link = await rtw.resolve('now://yourorg.morph.space/sensors/roof/temp')

link.on('change', (state) => {
  console.log('temp is now', state.celsius)
})

change fires once immediately with the current value, then again every time the source updates.

3. Write back

If your identity has write permission on the target, the same handle sends updates upstream:

await link.set({ setpoint: 21.5 })

4. Fan sources into a channel

To follow several sources as one stream, create a Data Channel and subscribe to it instead:

const channel = await rtw.channel([
  'now://yourorg.morph.space/sensors/roof/temp',
  'now://yourorg.morph.space/sensors/roof/humidity',
  'now://partnerorg.morph.space/weather/forecast',
])

channel.on('change', (state) => render(state))

The consumer sees one subscription; the partner org’s source is reachable through the channel but never directly.

Next steps