> For the complete documentation index, see [llms.txt](https://developers.verida.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.verida.network/protocol/client-sdk/events.md).

# Events

Your application can listen to events for when data changes in your application.

## Data changes[​](https://developers.verida.network/docs/client-sdk/events#data-changes) <a href="#data-changes" id="data-changes"></a>

Once a `datastore` or `database` is opened, you can listen to changes to automatically update your application:

```typescript
const filter = {
    status: 'active'
}

const listener = await database.changes(function(row) {
  console.log("Row changed", row)
}, filter)
```

Try this out with your own profile data in the browser in our [tutorial](https://developers.verida.network/docs/tutorial/events).

Options:

* `filter`: An optional JSON object. The listener will only raise events if the data in the object matches the supplied filter.

You can cancel the event listener:

```typescript
listener.cancel()
```

Similarly you can call:

```typescript
const listener = await datastore.changes(function(row) { ... })
```

## Inbox messages[​](https://developers.verida.network/docs/client-sdk/events#inbox-messages) <a href="#inbox-messages" id="inbox-messages"></a>

You can be notified when a new inbox message arrives for your application:

```typescript
const messaging = await context.getMessaging()
messaging.onMessage(function(message) { console.log('New message!', message)})
```

## Database sync changes[​](https://developers.verida.network/docs/client-sdk/events#database-sync-changes) <a href="#database-sync-changes" id="database-sync-changes"></a>

Data is automatically synchronized from remote encrypted servers to the local client. It’s possible to listen to events related to this syncing behavior:

```typescript
const listener = database.onSync('error', (err) => { console.log(err) })
listener.cancel()
```

A full list of events is available via the [PouchDB Documentation](https://pouchdb.com/api.html#sync)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://developers.verida.network/protocol/client-sdk/events.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
