Skip to content
Source
Sign inSign up
samwillis/hackernews-realtime
Open History to see the last commit

neon-staging.md

90 lines4.4 KB

Neon staging setup notes

These notes summarize the user-supplied NEON_REALTIME_SETUP.md, dated 2026-10-09, and the local Realtime examples. They are setup reference for the implementation. A dedicated demo project has now been provisioned in Sam's staging organization.

ResourceValue
Projecthackernews-realtime (square-paper-24289554)
OrganizationSam (org-wandering-poetry-25631650)
Branchmain (br-wild-star-w2vj64gc)
Region / databaseaws-us-east-2, PG18, neondb
Function / schedulehningest / hnminute, every minute

Realtime, logical replication, Functions and scheduled triggers are working together on this branch. Credentials are in the ignored .env.local; raw management responses are in ignored .local/. The example project in the attachment was not used.

Environment

Set both hosts when running the Neon CLI against staging:

export NEON_API_HOST=https://console-stage.neon.build/api/v2
export NEON_OAUTH_HOST=https://oauth2-stage.neon.build

Use neon --profile staging ... for the staging credential profile. The profile selects credentials; it does not change the API or OAuth host.

Reuse existing staging authentication when available. If authentication is missing, sign in against staging with both host variables set. Choose the organization at provisioning time; do not assume the example organization in the supplied guide is the intended owner of this demo.

Project requirements

  • Create a dedicated demo project in a staging organization. The supplied guide reports a zero project limit for personal staging accounts.
  • Use PostgreSQL 18 and aws-us-east-2, the region tested in the supplied guide.
  • Confirm Functions, scheduled Function Triggers, and Realtime are available together for that organization and region.
  • Enable logical replication before starting ingestion. The examples warn that this restarts computes and cannot be reversed.
  • Allow the exact local and deployed browser origins when enabling Realtime.

Prerelease tooling

The build pins Neon commit 3c08c9b45a919515a7b79977fa6267f828ce52d5, which includes the merged CLI Realtime support, in neon-toolchain.lock.json. The supplied guide describes older placeholder npm packages, while the local examples reference 0.0.1; verify package contents instead of treating either version number as proof of a usable release.

Keep generated tarballs in .sdk/, which is gitignored. Scripts should accept NEON_PKGS_DIR as a verified local override. The default bootstrap fetches pinned commits and generates packages before installing app dependencies; follow prerelease build and deployment. Verify that a fresh checkout produces identical package integrity values and a working prebuilt Vercel artifact, without relying on a developer's local checkout.

The guide also describes a fallback using neon api to call the Realtime management routes when the installed CLI lacks first-class support. Recheck the current routes before using that fallback.

Secrets and URLs

  • Use .env.local for application secrets. Preserve existing custom variables when pulling Neon-managed values.
  • Use the pooled database URL for ordinary application traffic and the direct URL for schema setup.
  • Keep NEON_REALTIME_SECRET server-only. It can seal arbitrary queries.
  • Convert the Realtime HTTPS invocation_url to wss:// for the SDK, without adding a path suffix. The SDK supplies the required WebSocket subprotocol.
  • Publish only the WebSocket URL as NEXT_PUBLIC_NEON_REALTIME_URL.
  • Neon Functions inject their branch's database URLs at runtime; avoid copying the application database credentials into Function deployment configuration.
  • Write raw project-creation responses under .local/ if needed: they can contain database passwords and must never be committed.

References