C&C Docs
Log in
Platform services

$toast and $notify

$toast tells the person looking at the page, right now, without stopping them. $notify tells somebody who may not be looking at all: it is a row with a recipient, delivered after the request ends.

A toast, from the browser or the server

Call $toast in browser code or in a server method: the toast raised on the server rides back with the reply, and the <cnc-toast> on this page shows both the same way.

// In the browser:
inBrowser() {
  this.$toast('raised in the browser', 'success')
}

// On the server, in a $-method:
async $saved() {
  // …write the row…
  this.$toast('saved by a server method', 'success')
}

A notification is a row, for somebody

$notify.app(name, scope) records a notification for whoever is signed in (or for scope.createdFor) and answers the row at once. $notify.email turns it into an _Email instead, and plain $notify lets the recipient choose.

async $raise() {
  const row = await this.$notify.app('welcome', { greeting: 'Hello' })
  row._key        // '_Notification/…', answered straight away
  row.createdFor  // you
}

this.$notify.email('welcome', { to: me.email })
this.$notify('welcome', { createdFor: otherUser })

A notification is always for somebody. Log in or create an account to raise one for yourself.