A reactive app updates itself when its data changes. Your components declare the data they need, and the system keeps that data in sync, so there's no fetch-and-refresh code to write.
Realtime builds this on live SQL queries. Its reactive client primitives bind each live query to your application state, end to end and type-safe, on standard Lakebase Postgres.
Reactive client primitives
- Type-safe live queries:
useLiveQuerybinds a sealed query to your component state, with the row type carried from your backend query. - TanStack DB collections: sync a live query into a TanStack DB collection for more advanced client-side data management.
- Optimistic mutations: apply writes locally first for instant feedback. The synced result replaces the optimistic state once the write lands.
Bind a live query to a component
In a React app, useLiveQuery binds a sealed query to your component, optionally starting from initialData loaded during SSR:
YourApp.tsx
import { useLiveQuery } from "@neon/realtime-react"
import type { SealedLiveQuery } from "@neon/realtime/client"
interface Props {
sealedQuery: SealedLiveQuery<Message>
initialData?: Message[]
}
export function Messages({ sealedQuery, initialData }: Props) {
const { data } = useLiveQuery(sealedQuery, { initialData })
return (
<ul>
{data.map((message) => (
<li key={message.id}>{message.body}</li>
))}
</ul>
)
}The component re-renders whenever a write changes the query's results.
Next steps
- Client-side reactivity: bind live queries to your app state
- Optimistic mutations: apply writes locally while they sync
- Next.js example: build a reactive app with Next.js and SSR
- TanStack example: build a reactive app with TanStack Start and DB
- TypeScript SDK: reference for the React and TanStack DB integrations








