neon

Integrates Neon Postgres with a PGLite fallback into a TanStack Start app.

Updated Sep 17, 2026
One-click install
npx skills add https://github.com/scomofo/midi-stage2 --skill neon-scomofo
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: neon
Source: https://github.com/scomofo/midi-stage2/tree/main/.grok/skills/neon
Command: npx skills add https://github.com/scomofo/midi-stage2 --skill neon-scomofo

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires pg, @electric-sql/pglite.

What problem does it solve? Adding persistent, server-side data storage to a TanStack Start app requires provisioning a database, managing connection strings, writing migrations, and keeping the dev preview consistent with production. This Skill provides a prewired dual-mode database integration that handles all of that. ## Core Features & Use Cases - Dual-mode database access: Uses real Neon Postgres when DATABASE_URL is set at deploy time, and automatically falls back to an embedded PGLite (WASM Postgres) in the sandbox preview, both through the same @/lib/db API. - Server-only queries: Exposes getSql() with a tagged-template and .query() interface, callable only from createServerFn handlers or server loaders, with optional authMiddleware scoping for per-user data. - Ordered SQL migrations: Applies migrations/*.sql to Neon on deploy via npm run build and to the PGLite preview automatically on startup, keeping dev and prod schemas in sync. - Use Case: You are building a todos app and need tasks to persist across sessions. Enable the database flag, add a 0002_schema.sql migration with a todos table, and query it from a server function — the preview works immediately on PGLite and the deploy runs on Neon with no extra setup. ## Quick Start Ask the AI to add a database-backed feature, such as "create a todos table with a migration and a server function that lists and adds todos using the Neon database skill."

Frequently Asked Questions about neon

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a Postgres database to a TanStack Start app?▼

Set `deploy.database` to true in `.grok/app-env.json`, define your schema in ordered files under `migrations/`, and query through `getSql()` from `@/lib/db` inside a `createServerFn` handler. The platform injects `DATABASE_URL` on deploy; never create a `.env` file yourself.

How do database migrations work with Neon and PGLite?▼

Migrations live as ordered SQL files in `migrations/` and are the single schema source. `npm run build` applies them to Neon on deploy, while the PGLite preview applies them automatically on startup. Never edit an applied file; add a new one instead.

Can I use the database without setting up user authentication?▼

Yes, but rows stay unowned and world-readable through your public server functions. Do not store personal or sensitive data, avoid destructive bulk mutations, and do not use `authMiddleware` until sign-in is enabled via the separate auth skill.

Why does my preview database lose data after restarting the dev server?▼

The preview uses an in-memory PGLite instance that is wiped on every dev-server restart. It is single-connection and loads no extensions, so avoid `create extension`, session state, and advisory locks that would work differently on deployed Neon.

What are the limitations of the PGLite fallback compared to Neon?▼

PGLite is in-memory, single-connection, and supports no Postgres extensions, while Neon queries traverse the network and may cold-resume. Keep `user_id` columns as text, cast huge bigints to text, and avoid N+1 query patterns that feel free against the in-process preview.