PRO

Neon HTTP Composable SQL

A query module for edge handlers built on the composable HTTP query path that @neondatabase/serverless shipped in 1.0.0. Compilation to SQL-with-placeholders moved to query time, so a sql fragment is inert until an outer query consumes it and its parameters get renumbered in traversal order; this snippet uses that to turn optional status, search, date, and service filters into fragments folded pairwise into one WHERE clause, replacing the string concatenation or the one-query-per-filter-combination that 0.x forced. It documents the traps the release notes skip: an interpolated array of fragments binds as a single parameter instead of composing, and a parameterized sql.query() result throws a not-composable error, which makes it a whole-query escape hatch rather than a fragment. The client pins down what one-shot HTTP cannot do, covering non-interactive sql.transaction, no surviving session state, and the WebSocket Pool path for anything needing BEGIN, and explains why sql(...) with parentheses now throws so a 0.x migration knows what broke.

Install
npx shadcn@latest add https://ui.aryank.space/r/neon-http-composable-sql.json

Installs from ui.aryank.space. To add it by hand, copy the files in Files below, or register the @compronents namespace via the docs.

Visualization
fragment
IncidentFilters
query
unknown
const f = status ? sql`AND status = ${status}` : sql``; await sql`SELECT * FROM incidents ${f}`

A sql fragment stays inert until an outer query consumes it, renumbering placeholders in traversal order, so optional filters compose safely.

Files

Dependencies
@neondatabase/[email protected]