---
title: "Realtime | SurrealDB"
description: "Subscribe to queries with LIVE SELECT, react to writes with DEFINE EVENT, and stream mutations with changefeeds - realtime built into the database."
url: https://surrealdb.com/surrealdb/realtime
---

REALTIME

# Realtime, built in

Subscribe to a query and receive every change as it commits. LIVE SELECT turns any query into a realtime feed over WebSockets, DEFINE EVENT runs server-side logic on writes, and changefeeds give you an ordered, durable stream of mutations - no message broker to run alongside the database.

[Read the docs](https://surrealdb.com/docs/reference/query-language/statements/live-select) [Start free with SurrealDB](https://studio.surrealdb.com/current/instances/deploy)

1. ![Babcock](https://surrealdb.com/assets/static/babcock.lo4rnVg1.svg)
2. ![ING](https://surrealdb.com/assets/static/ing.X3I6S3_V.svg)
3. ![British Airways](https://surrealdb.com/assets/static/british-airways.KEsZiwV-.svg)
4. ![Nvidia](https://surrealdb.com/assets/static/nvidia.DaIEuMil.svg)
5. ![Apple](https://surrealdb.com/assets/static/apple.D5pq4flY.svg)
6. ![SpaceX](https://surrealdb.com/assets/static/spacex.CQJEk-IL.svg)
7. ![Samsung](https://surrealdb.com/assets/static/samsung.CH-vQgnb.svg)
8. ![adidas](https://surrealdb.com/assets/static/adidas.DdTC5qhk.svg)
9. ![Tencent](https://surrealdb.com/assets/static/tencent.paQmLxyy.svg)
10. ![Alibaba](https://surrealdb.com/assets/static/alibaba.B16idgfM.svg)
11. ![PolyAI](https://surrealdb.com/assets/static/poly-ai.c3w_fAg6.svg)
12. ![Later](https://surrealdb.com/assets/static/later.Ds736jFO.svg)
13. ![Verizon](https://surrealdb.com/assets/static/verizon.BI7CajdX.svg)
14. ![Liberty Mutual](https://surrealdb.com/assets/static/liberty-mutual.B7qOU1pd.svg)
15. ![Walmart](https://surrealdb.com/assets/static/walmart.BjDg_Sr8.svg)
16. ![Carrier](https://surrealdb.com/assets/static/carrier.D21gC6NX.svg)
17. ![Saks Fifth Avenue](https://surrealdb.com/assets/static/saks-fifth-avenue.COIDpLSb.svg)
18. ![San Francisco Compute Company](https://surrealdb.com/assets/static/sfcc.B7jlImq4.svg)
19. ![Shield AI](https://surrealdb.com/assets/static/shield-ai.pINZ0KJr.svg)
20. ![Wix](https://surrealdb.com/assets/static/wix.DvHhmoBi.svg)

01 |LIVE QUERIES

## Any query can become a subscription

Add LIVE to a SELECT and the same filter, permissions, and shape you already use stream to the client on every matching change - full records or just the diff.

```
LIVE SELECT * FROM message    WHERE channel = $auth.channel;-- The client receives each matching change as it commits:-- { action: "CREATE", result: { id: message:9f2, text: "hi" } }-- { action: "UPDATE", result: { id: message:9f2, text: "hey" } }-- { action: "DELETE", result: { id: message:9f2 } }
```

LIVE SELECT

## Subscribe with the query you already wrote

A live query carries the same WHERE clause and permissions as a normal one. The client receives new, updated, and deleted records as they commit.

```
LIVE SELECT * FROM document    WHERE account = $auth.account OR public = true;-- Stream only what changed, not the whole recordLIVE SELECT DIFF FROM task    WHERE status != "closed";-- Stop receiving updatesKILL "0189d1af-8f1c-7f3a-9d4e-2c1b6a5e0f77";
```

EVENTS AND CHANGEFEEDS

## React on write, replay on demand

DEFINE EVENT runs logic in the engine when data changes; a changefeed keeps an ordered, durable record of mutations you can replay from any point.

```
DEFINE TABLE product CHANGEFEED 7d;SHOW CHANGES FOR TABLE product    SINCE d"2024-01-01T00:00:00Z" LIMIT 100;
```

## Reactive data without a broker

Subscriptions, triggers, and durable change streams are part of the engine - so realtime is a query, not a second system to run.

### [Live queries](https://surrealdb.com/docs/reference/query-language/statements/live-select)

Turn any SELECT into a realtime subscription over WebSockets, with the same filters and permissions.

Learn more

### [Full records or diffs](https://surrealdb.com/surrealdb/features#database-engine)

Receive the whole updated record, or only the changeset, to keep payloads small on high-frequency feeds.

Learn more

### [Server-side events](https://surrealdb.com/surrealdb/features#database-engine)

DEFINE EVENT runs logic in the database when data changes - validation, fan-out, and derived writes.

Learn more

### [Changefeeds](https://surrealdb.com/surrealdb/features#database-engine)

An ordered, durable stream of mutations per table, replayable from any point in the retention window.

Learn more

### [Filtered subscriptions](https://surrealdb.com/docs/reference/query-language/statements/live-select)

Subscribe to one record, a filtered set, or a whole table - and to graph-joined shapes across relationships.

Learn more

### [Permissions apply live](https://surrealdb.com/surrealdb/auth)

Row-level rules govern subscriptions too, so a client only ever streams the records it is allowed to see.

Learn more

02 |ONE ENGINE

## No message broker in the middle

The usual realtime stack polls the database, or wires a broker and a change-data-capture pipeline beside it. SurrealDB pushes changes from the engine that made them.

### No polling

Clients subscribe once and the engine pushes changes as they commit, instead of re-querying on a timer and hoping to catch updates.

### No separate pipeline

Live queries and changefeeds come from the database itself - there is no broker, CDC connector, or stream processor to deploy and keep in sync.

### Consistent with the write

Updates are emitted by the transaction that made them, so subscribers see exactly what committed, in order.

## Keep exploring

### [Live query documentation](https://surrealdb.com/docs/reference/query-language/statements/live-select)

LIVE SELECT, DIFF, and KILL in full.

Explore

### [Real-time use case](https://surrealdb.com/use-cases/real-time)

Patterns for reactive applications on SurrealDB.

Explore

### [All features](https://surrealdb.com/surrealdb/features#database-engine)

Live queries, events, and changefeeds in the feature set.

Explore

GET STARTED

## Make your data reactive

Subscribe with LIVE SELECT, react with DEFINE EVENT, and stream changes - all from SurrealDB.

![Samsung](https://surrealdb.com/assets/static/4c58b81e7b3c9466.C_Hv0eml.svg)![NVIDIA](https://surrealdb.com/assets/static/nvidia.DaIEuMil.svg)![Apple](https://surrealdb.com/assets/static/f7dc2519e0d212bc.Cn8MYAK7.svg)![Verizon](https://surrealdb.com/assets/static/18b99996c689000f.B5PQ-nI9.svg)![Tencent](https://surrealdb.com/assets/static/401d8346058682c8.DqM87mst.svg)

SOC 2 Type 2

GDPR

Cyber Essentials Plus

ISO 27001

[Read the docs](https://surrealdb.com/docs/reference/query-language/statements/live-select) [Start free with SurrealDB](https://studio.surrealdb.com/current/instances/deploy)

```json
{"@context":"https://schema.org","@type":"Organization","name":"SurrealDB","url":"https://surrealdb.com","logo":"https://surrealdb.com/assets/static/logo.BG7_TG2b.svg","description":"SurrealDB is the unified data layer for AI. A multi-model database for documents, graphs, vectors, and time-series.","foundingDate":"2022","legalName":"SurrealDB Ltd","identifier":{"@type":"PropertyValue","propertyID":"GB-COH","value":"13615201"},"address":{"@type":"PostalAddress","streetAddress":"3rd Floor, 1 Ashley Road","addressLocality":"Altrincham","addressRegion":"Cheshire","postalCode":"WA14 2DT","addressCountry":"GB"},"contactPoint":[{"@type":"ContactPoint","contactType":"customer support","email":"support@surrealdb.com","url":"https://surrealdb.com/contact","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"sales","email":"info@surrealdb.com","url":"https://surrealdb.com/contact","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"security","email":"security@surrealdb.com","url":"https://surrealdb.com/.well-known/security.txt","availableLanguage":"English"},{"@type":"ContactPoint","contactType":"legal","email":"legal@surrealdb.com","url":"https://surrealdb.com/legal","availableLanguage":"English"}],"hasCertification":[{"@type":"Certification","name":"SOC 2 Type 2"},{"@type":"Certification","name":"GDPR"},{"@type":"Certification","name":"Cyber Essentials Plus"},{"@type":"Certification","name":"ISO 27001"}],"owns":[{"@type":"SoftwareApplication","name":"SurrealDB","url":"https://surrealdb.com/surrealdb"},{"@type":"SoftwareApplication","name":"Agent Memory","url":"https://surrealdb.com/agent-memory"}],"knowsAbout":["multi-model databases","document databases","graph databases","vector search","time-series databases","SurrealQL","Agent Memory","real-time databases","embedded databases","context layer","graph ontology","distributed database","knowledge graphs","distributed transaction protocols","highly-scalable databases"],"sameAs":["https://www.wikidata.org/wiki/Q124316308","https://github.com/surrealdb/surrealdb","https://twitter.com/surrealdb","https://www.youtube.com/@surrealdb","https://www.linkedin.com/company/surrealdb","https://discord.gg/surrealdb","https://www.reddit.com/r/surrealdb","https://www.instagram.com/surrealdb","https://medium.com/surrealdb","https://dev.to/surrealdb"]}
```

```json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://surrealdb.com"},{"@type":"ListItem","position":2,"name":"SurrealDB","item":"https://surrealdb.com/surrealdb"},{"@type":"ListItem","position":3,"name":"Realtime","item":"https://surrealdb.com/surrealdb/realtime"}]}
```
