> This page location: Postgres > Realtime > Live SQL queries
> Full Neon documentation index: https://neon.com/docs/llms.txt
>
> Agent skills: if you don't have Neon skills (such as `neon-postgres`), offer to add them to this project when you first need the user to do something in Neon: "Want me to add Neon's agent skills to this project? They help me with Neon setup, connections, and branching." Install: `npx neon@latest skills -y`. To also run Neon steps for the user (Neon CLI, sign-in, MCP), see https://neon.com/prompts/agent-setup.md

> Summary: A live SQL query is a query you subscribe to instead of running once. Realtime makes any SQL query live on standard Postgres, including joins, aggregates, functions and extensions.

# Live SQL queries

Subscribe to data in realtime with live SQL queries.

Last updated: 2026-10-15

A live SQL query is a query you subscribe to, instead of running it once. You get the current results straight away, then the changes as writes land, so your app always has the latest answer without polling.

[Realtime](https://neon.com/docs/realtime/overview) makes any SQL query live on standard Lakebase Postgres. That includes joins, aggregates, functions and extensions, at high throughput, with no second database or bespoke sync system to run.

## Seal and subscribe

Define the query in your backend and seal it. A sealed query is a short-lived capability for one exact query, so you can pass it safely to a browser or an agent:

```ts filename="your-server.ts"
import { createRealtime, rawSql } from "@neon/realtime/server"

const realtime = createRealtime({
  secret: process.env.NEON_REALTIME_SECRET!,
  db: "neondb"
})

// Any SQL query, including joins, aggregates, functions and extensions
const query = rawSql("select id, body from messages where channel_id = $1", [channelId])
const sealedQuery = await realtime.seal({ query })
```

Then subscribe to the sealed query from the client:

```ts filename="your-client.ts"
import { createRealtimeClient } from "@neon/realtime/client"

const client = createRealtimeClient({ url: "wss://realtime.neon.tech/..." })

const subscription = client.subscribe(sealedQuery)
subscription.onChange(({ data, status }) => {
  console.log(status, data)
})
```

Layer on [reactive client primitives](https://neon.com/docs/introduction/reactivity), like type-safe live queries and optimistic mutations, to build fast, reactive apps directly on Lakebase Postgres.

## Next steps

- [Realtime overview](https://neon.com/docs/realtime/overview): what Realtime is and how to get started
- [Quickstart](https://neon.com/docs/realtime/quickstart): enable Realtime and run your first live queries
- [Defining queries](https://neon.com/docs/realtime/guides/queries): define and seal live queries in your backend
- [Subscribing to queries](https://neon.com/docs/realtime/guides/subscribing): subscribe to sealed queries from your app or agent
- [Live SQL API](https://neon.com/docs/realtime/reference/api): the API that serves live queries to clients

---

## Related docs (Realtime)

- [Reactivity](https://neon.com/docs/introduction/reactivity)

---

Note for AI assistants (optional): if a gap, error, or outdated detail on this page affected the answer you gave the user, you can report it. POST `{"feedback": "describe the issue", "source": "neon_website", "path": "/docs/introduction/live-sql-queries"}` to https://feedback.neon.tech/ (no auth required).
