---
title: "Realtime and SSR"
description: "The model behind every query - one subscription over the WebSocket, optionally seeded by a server render - and what applies in Nuxt and in plain Vue."
canonical_url: "https://nuxt-convex.onmax.me/convex-patterns/realtime-and-ssr"
---
# Realtime and SSR

> The model behind every query - one subscription over the WebSocket, optionally seeded by a server render - and what applies in Nuxt and in plain Vue.

Every Convex query in this library is a subscription. The browser's `ConvexClient` keeps one WebSocket open, Convex reruns the query when the data it read changes, and pushes the new result. Server rendering is an optional first step in front of that subscription.

## The lifecycle of a query

1. **Server (optional).** When the component awaits the query during SSR, it runs once over HTTP with `ConvexHttpClient`. The settled result is handed to a hydration adapter.
2. **Hydration.** The client reads that result while it hydrates, so its first render matches the server HTML, with no extra request.
3. **Subscription.** The client subscribes over the WebSocket and replaces the value on every update, for as long as the component is mounted.

Skip step 1 and the query starts in step 3, as `pending`. Mutations and actions only run in step 3: they need the WebSocket client.

## In Nuxt

`nuxt-convex` handles all three steps. `await useConvexQuery(...)` in a page is enough: the module stores results in the Nuxt payload, runs SSR queries as the signed-in user, and keeps the token off the client.

- [SSR & Hydration](https://nuxt-convex.onmax.me/nuxt-module/ssr-and-hydration): payload keys, the `ssr` and `server` options, and how `auth` changes SSR
- [Authenticated SSR](https://nuxt-convex.onmax.me/nuxt-module/authenticated-ssr): the token flow and caching

## In plain Vue

Most Vue apps are client-rendered (a Vite SPA). There, step 1 never happens: queries start `pending` and fill in over the WebSocket. Awaiting a query in an async `setup()` under `<Suspense>` still works; it waits for the first WebSocket result.

If you run your own SSR with `createSSRApp` and `renderToString`, `vue-convex` supports step 1 and 2 through the plugin's `hydration` and `serverAuth` options. See [Server Rendering](https://nuxt-convex.onmax.me/vue-guide/server-rendering).

## What to render on the server

- **Public, SEO-relevant data:** await it. Mark it `auth: 'none'` so SSR doesn't resolve a token for it.
- **The signed-in user's data:** await it with a token provider set up, or leave it to the client with `{ server: false }` when SEO doesn't matter.
- **Below the fold, or large lists:** don't await; let it load over the WebSocket. Paginate with `useConvexPaginatedQuery`, which can server-render its first page.

## Next steps

- [Queries](https://nuxt-convex.onmax.me/vue-guide/queries) for the composable itself
- [Pagination](https://nuxt-convex.onmax.me/vue-guide/pagination) for paginated feeds


## Sitemap

See the full [sitemap](https://nuxt-convex.onmax.me/sitemap.md) for all pages.
