Skip to content

Neon.Data API reference

Source: src/Neon/DataApi.ts

Own a branch/database Data API singleton. This resource never grants an application the account deployment key. Configure RLS and forward the user’s token through QueryDataApi. Authentication inputs are creation-only because the API only supports updating PostgREST settings.

DataApi: Expose a database through managed authentication

Section titled “DataApi: Expose a database through managed authentication”
const dataApi = yield* Neon.DataApi("Data", {
branch, authProvider: "neon_auth", settings: { db_max_rows: 100 },
});

Source: src/Neon/QueryDataApi.ts

Query Neon Data API (PostgREST) over HTTP from a Function, Worker, or Lambda using an explicitly supplied caller token. Supports reads, writes and database function calls; this binding does not provision database grants or RLS policies.

This is a low-level Effect HTTP client, not a SQL driver or a fluent query builder. Browser applications can use Neon’s @neondatabase/neon-js or @neondatabase/postgrest-js SDK directly with the public Data API URL.

Relative URLs cannot redirect the authorization header to another origin. Requests do not follow redirects, and response bodies remain request-scoped.

QueryDataApi: Forward end-user authorization

Section titled “QueryDataApi: Forward end-user authorization”
const data = yield* Neon.QueryDataApi(dataApi);
// In the request handler, after obtaining the caller's token:
const response = yield* data.execute(HttpClientRequest.get("todos?select=*"), token);