Skip to main content
Build your agent on Neon and provision backends you fully control. See how Ideavo does it
/Realtime/Quickstart

Quickstart

Get started with Realtime.

View as Markdown

Enable Realtime, run your first live SQL queries and build an app with realtime reactivity.

Create your project in a supported region

Realtime is currently available in limited regions. Support is expanding toward all regions.

Realtime isn't available on Claimable projects until they're claimed.

Get started

You'll need Node.js 22 or later and the Neon CLI:

Terminal
npm i -g neon
  1. Log in to Neon, then link a new, empty directory to a Neon project:

    Terminal
    neon login
    neon link

    neon link asks which project to use. Pick an existing project or create a new one. Either way, it needs to be in a supported region.

  2. Enable Realtime

    You can enable Realtime in the Neon Console or using the CLI.

    In the Neon Console

    In the Neon Console, select your project and then Postgres database > Realtime to navigate to the Realtime page.

    Realtime page with enable button

    Click Enable Realtime. Once enabled, you'll see the Realtime page:

    Realtime enabled view

    The page gives you the two values your app needs:

    • Realtime SQL API endpoint URL: your Live SQL API endpoint. Use it as the value for NEON_REALTIME_URL.
    • Copy secret: copies the branch's shared secret, which you use when sealing queries. The Console doesn't display the secret. Use it as the value for NEON_REALTIME_SECRET.

    Using the CLI

    Run neon realtime enable to enable Realtime for the currently linked project and branch:

    Terminal
    neon realtime enable

    To get the URL and secret that the Console shows, you can run:

    Terminal
    neon env pull --service realtime

    It writes them to .env.local as NEON_REALTIME_URL and NEON_REALTIME_SECRET.

  3. Subscribe to a live query

    The simplest way to try live queries is with the Neon CLI. First, if you need to, create a table to query and insert some data into it:

    Terminal
    neon psql -- -c "CREATE TABLE items (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), value TEXT)"
    neon psql -- -c "INSERT INTO items (value) VALUES ('foo')"

    Then use neon realtime subscribe to start a live query:

    Terminal
    neon realtime subscribe "SELECT * FROM items"

    This keeps running until you stop it with Ctrl+C. To see the result update, open a second terminal in the same directory and insert another row:

    Terminal
    neon psql -- -c "INSERT INTO items (value) VALUES ('bar')"

    By default, neon realtime subscribe prints the full query result every time it changes. To see the underlying delta sync instead, subscribe to the raw changes:

    Terminal
    neon realtime subscribe --changes "SELECT * FROM items"

    See neon realtime subscribe for JSON output and the other options.

Build a realtime app

The realtime-react starter template is a shared todo app built with React, Vite, a Hono API and Drizzle, with optimistic updates.

Scaffold it with neon bootstrap:

Terminal
neon bootstrap my-app --template realtime-react

Bootstrap scaffolds the app, installs the dependencies and links the new my-app directory to a Neon project via neon.ts config.

If the branch doesn't have Realtime yet, the link step can't pull the env vars and prints a warning to run neon deploy. That's the next step.

Run neon deploy to apply the generated config, enabling Realtime for your project and branch:

Terminal
cd my-app
neon deploy

This automatically writes your DATABASE_URL, NEON_REALTIME_URL and NEON_REALTIME_SECRET to .env.local. You can then run migrations and start the app:

Terminal
npm run db:setup
npm run dev

Open http://localhost:5173 in your browser. If you open two windows or tabs, as you change data in one, you'll see it update in realtime in the other.

Agent skills and MCP

Install the Neon MCP server. Or use the CLI to install the Realtime skill:

Terminal
neon skills -s neon-realtime
Copy this to your coding agent to get started with Realtime.

Manage Realtime

On the Realtime page in the Neon Console:

  • Rotate secret replaces the branch's shared secret. Once rotation finishes, the old secret stops working, so click Copy secret and update NEON_REALTIME_SECRET in every app that uses it.
  • Disable Realtime disconnects all Realtime clients on the branch and discards its shared secret.

To do the same from the CLI, and for details on how rotation and disabling work, see neon realtime rotate-secret and neon realtime disable.

Next steps

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Last updated on

Was this page helpful?
Edit on GitHub