Documentation

Docs / Reference

Claim contract: Next.js and Supabase

The claim contract tables for Next.js routes, server actions and Supabase (ADR 0077) as recorded when the feature was designed (task T024, internal record). The code tables in internal/index, internal/extract/schema, internal/extract/models/supabasetypes and internal/extract/tableaccess are kept 1:1 with these rows by their contract tests.

Claim contract: Next.js routes (T024a, rows NX)

Assumptions:

id form claim refusal / unknown assumptions
NX-P1 a scanned package.json declaring next in dependencies or devDependencies, whose directory holds app/ (else src/app/) and/or pages/ (else src/pages/) a Next.js project rooted there; its app directory and pages directory (Next.js findPagesDir) app and pages under different parents (Next.js refuses): project unread, diagnostic nextjs_project_unread -
NX-P2 next.config.{js,mjs,cjs,ts,mts} in the project directory whose default export / module.exports is an object literal, a const bound to one, or plugin calls (nested or not) each wrapping that one argument; a spread of object literals (or of a conditional between them) makes only the keys those literals name unread, any other spread every key the literal does not name basePath (string literal), trailingSlash (boolean literal), pageExtensions (array of string literals); absent keys take Next.js defaults ("", false, tsx ts jsx js) any other value of the three keys, a function config, an unreadable file: basePath unresolved (base: unresolved on every path entry), trailingSlash unknown (flag omitted), pageExtensions non-literal: the project's routes go to D (nextjs_config_unread) NX-V2
NX-P3 the rewrites key of an NX-P2 config object: a function (method, arrow or async) whose body returns, or an arrow whose body is, an array literal, or an object literal with beforeFiles / afterFiles / fallback array literals; every element an object literal with only source and destination string literals, source a path of literal segments and :name, :name*, :name+, :name? parameters the project's literal rewrite rules (phase, source, destination), recorded on the project anything else (a variable, a call, push, has / missing / basePath / locale keys, regex groups): rewrites unread (diagnostic nextjs_rewrites_unread, info); linking continues under NX-V1, which says so NX-V2
NX-R1 a file route.<ext> (ext from pageExtensions) under the app directory, no directory part starting with _ the route template: each directory segment in order; (name) group and @slot dropped; [n] becomes {n}; [...n] becomes {*n}; [[...n]] becomes {*n} with optional: true; other segments literal; / when nothing remains a part starting with _ (private folder): not a route, no record; an intercepting segment (.)x, (..)x, (...)x, (..)(..)x; a %-escaped segment; a segment with brackets of another shape; a page.<ext> in the same directory (Next.js build error): D, nextjs_route_unread info -
NX-R2 in an NX-R1 file, an export named GET, POST, PUT, PATCH, DELETE, HEAD or OPTIONS: export [async] function, export const X = <expr>, export { a as X }, export { X } from "m", destructuring export const { X } = ... one level-4 route node per verb (framework: nextjs, method, pattern = template, paths per NX-R4); handler the function the binding resolves to through the shared TypeScript export resolver, else null with handler_expression; resolved handlers get exposes_route (fact) export * that the shared resolver cannot expand: D (nextjs_route_exports_unknown); lowercase get etc. and other names (runtime, dynamic, helpers): not routes -
NX-R3 (O2 (a)) a file <pagesDir>/api/**.<ext> (ext from pageExtensions) with a default export one route node ANY (framework: nextjs_pages), template from the path with index stripped and NX-R1's bracket rules no default export, a .d.ts file: D; a template NX-R1 refuses: D (nextjs_route_unread). An _-prefixed file or folder under api/ is a route (T024 review: next 14.1.0 to 16.4.2 collect pages without the App Router's private-folder filter; only _app, _document and _error at the pages root are reserved) -
NX-R4 path composition for NX-R2/NX-R3 routes one path entry: basePath + template, slash-normalized as ADR 0013; resolution: literal (no or literal basePath) or base unresolved (NX-P2 refusal); trailing_slash: true when trailingSlash is literally true; optional from NX-R1 - -
NX-L1 an existing client_call alternative (fetch, axios, hey-api, Orval) Next.js routes join the matcher's candidates under the existing rules (ADR 0018, 0020); client HEAD matches a route GET (Next.js auto-implements HEAD); an auto OPTIONS is not a route; a call linked to a Next.js route carries assumes: ["NX-V1"] same-origin rule: an alternative with a literal origin never matches a Next.js route (it stays as today); (T024 review) an alternative in a file of a Next.js application (the deepest NX-P1 directory holding it) has only that application's routes as Next.js candidates, and one in a file outside every application, in a repository with several, never links to a Next.js route (ambiguous, nextjs_origin: unknown, the matching routes as candidates: the file may run in any of them); a route path with base unresolved matches only an alternative whose base is unresolved too, and such a link is aligned with the unknown-prefix tier (decision U6 of T033, row UP-19 of the unknown-prefix claim contract): match: suffix, route_prefix: unresolved, confidence 0.6, assumes NX-V1, UP-V1, UP-V2; an alternative matching both a Next.js and another framework's route: ambiguous as today; a call from another repository of a project is matched by the project link pass under its own rules (docs/extract/project-links.md, "Next.js route targets"; TOP-1 of 2026-11-18) NX-V1
NX-L2 useSWR(k, f) / useSWRImmutable(k, f) from swr (shared resolver); k a literal or bounded const string, or (T024a2) a key the bounded URL evaluator (ADR 0020) reads as strings only, where a null alternative (SWR's "do not fetch" key) drops out; f a resolved function forwarding its first parameter unchanged as the URL of a recognised fetch (existing wrapper rules), or (T024a2) an inline arrow function with one plain parameter whose expression body starts with a fetch or axios GET of that parameter without options, the only request inside the arrow a client_call node library: swr, method GET, paths from k (an environment base unresolved as for other clients), linked as NX-L1; an inline fetcher's own request node gets status: wrapper an array, function or null-only key, a key with any other value (a parameter, an object, a call), an unresolved or global fetcher (SWRConfig), an inline fetcher with a block body, options or another request: D (counted) NX-V1
NX-L3 an alternative whose path may match the source of an NX-P3 rule of the project whose routes are candidates (NX-L1) (T024a2) Next.js order (next 14.1.0 and 16.2.10 resolve-routes.js: beforeFiles, exact static check, afterFiles, route check, fallback); the first rule that may match decides. (1) Served first (T024 review), with a literal call base and project basePath: for an afterFiles rule, a static route of the project that surely serves the call path (equal literal segments), for a fallback rule any route that surely serves it, is matched as without the rule, whatever the rule's destination. (2) Re-routed: with a literal call base and project basePath, a source that surely matches (equal literal segments, same case, no trailing slash), a same-origin destination of literal segments and source parameters, and no later rule that may match the rewritten path before a route surely serves it: the project's routes are matched at the rewritten path; the path entry records nextjs_rewrite (source), nextjs_rewrite_destination, nextjs_rewrite_phase; an afterFiles or fallback link also assumes NX-V3 when (1) does not apply: a route that only may serve the path (a call parameter against a literal, a case difference), or any other may-match (an external, protocol-relative or unmapped destination, an unresolved base, a call parameter or a case difference against a literal source segment, a trailing slash, a chain): no Next.js route of that project is a candidate; the alternative records nextjs_rewrite: <source> NX-V1, NX-V3
D everything else: middleware / proxy, non-literal rewrites, redirects, headers, generateStaticParams, Pages Router pages, i18n locale prefixes, next/navigation and <Link> (navigation, not requests), Playwright request calls, app wrappers returned from hooks nothing; NX-R1 and NX-R2 refusals are counted (nextjs_route_unread) always -

Claim contract: server actions (T024b, rows SA)

Model per O1 (a) (decided): one level-4 server_action node per action (transport: server_action, contains from the declaring file or function, exposes_action fact edge from the action function), and, per use, an action_call node contained by the calling owner with a calls_action edge to the action (T024b clarification: edges carry no attributes, so a use's form and boundary are attributes of its node, as Tauri's ipc_call), shown in the API section as a third transport next to HTTP and Tauri IPC.

id form claim refusal / unknown
SA-M1 a file whose directive prologue holds 'use server' (TypeScript compiler semantics: leading string-literal expression statements), not 'use client'; each export: export async function, export const a = async (...) => ... / async function, export const a = <call> (a wrapper's result), export { a } of a local binding of those forms, (R1) export { a } of an imported binding (imported_clause: Next.js registers it, next-custom-transforms server_actions.rs; only an import of this file names the action), export default async function; (T024 review, server_actions.rs ExportDefaultExpr at next 14.1.0 to 16.4.2) export default async (...) => ... (default_async_arrow), export default <call> (default_call), export default a of a local binding of the forms above (default_clause) or of an imported binding (imported_clause) a server action named by the export (scope: module), its node pointing at the exported binding (for imported_clause the imported function, when resolved) a non-function export (export const x = 1, a class): D (a load error, ensureServerEntryExports); a sync function written in the file and exported directly, through export { a } or through export default: D (a build error at next 15.1.4 to 16.4.2, where every exported function inherits the file directive and must be async; at 14.1.0 only a sync function exported directly and a sync default arrow are build errors, while a sync arrow and a sync function exported by name are registered, since the runtime check tests only typeof === 'function': there D misses an action, never claims one); export { a } from and export *: D (build errors in server_actions.rs)
SA-I1 a named async function, or an async arrow / function expression bound to a const, (R1) let or var, whose body's directive prologue holds 'use server', in a file without 'use client' a server action (scope: inline); a let / var binding assigned anywhere in the file is reassigned: its uses are not linked anonymous inline actions (action={async () => { 'use server' ... }}): the action node with the enclosing owner, no name (R1: linked as the form's action by SA-C1); a sync function or a class method: D; in a 'use client' file: D (build error)
SA-C1 JSX attribute action={a} on an intrinsic <form> or on next/form's Form (its default import), or formAction={a} on an intrinsic <button> or <input> (T024 review: React's form actions), a resolving (shared resolver, through imports) to an SA-M1/SA-I1 action; (R1) an inline SA-I1 action written as the value; (R1) a conditional c ? a : b (nested, parenthesized) whose alternatives include such bindings an action_call node contained by the owner with a calls_action edge to the action; form: form_action; a conditional value is one use with conditional: true, alternatives and one calls_action edge per action alternative (each a possible submit target) any other expression (call, member), an unresolved binding: D (counted); action / formAction on any other element (a component's prop, which the component may use as it likes): D (counted, as a prop)
SA-C2 useActionState(a, ...) from react or useFormState(a, ...) from react-dom, a as in SA-C1 calls_action, form: action_state (conditional as SA-C1) as SA-C1
SA-C3 a direct call a(...), a resolving to an SA-M1/SA-I1 action calls_action, form: direct; boundary: client when the call's file has 'use client' in its prologue, or (R1) it is reached from such a file through resolved value imports and value re-export clauses (export { a } from, export *, export * as ns; the client module graph, mapped) and no server entry point (a file under app/ or pages/, middleware, instrumentation) reaches it through imports or re-export clauses that may load it (any that is not type-only; T024 review) without a 'use client' boundary, following also import() and require() of a string literal, and no file of the server graph holds one the resolver cannot follow (a non-literal or unresolved specifier; else server_graph_incomplete names the first); otherwise boundary: unknown (a module in both graphs also gets shared_module: true; never server, never client without that proof) an unresolved callee: D; the ordinary calls edge stays as today
D props passing an action to a component, .bind(...), actions read through objects, startTransition callbacks other than a direct call, dynamic import nothing linked; counted (server_action_use_unread); (R1) each action such a use names gets unread_uses and is never reported as not called always

Every action fact is mapped except the directive and the export names, which the TypeScript compiler oracle checks.

Claim contract: Supabase (T024c, rows SB)

Assumptions:

id form claim refusal / unknown assumptions
SB-M1 a directory supabase/ holding config.toml and migrations/; members per the Supabase CLI (pkg/migration): direct entries in lexical order, name ^([0-9]+)_(.*)\.sql$, the first file skipped when it is <14 digits>_init.sql older than 20211209000000 a migration set, tool: supabase, dialect postgres, read by the existing PostgreSQL 17 statement reader (ADR 0047, 0051) other names: ignored (as the CLI); an unreadable member: as sqlx sets (schema_member_unreadable, every table partial) -
SB-M2 a reference to a prelude object (auth.users, auth.uid(), storage.objects, storage.foldername(), the three roles) resolves to an external platform object: no schema_unresolved_reference, no partial table any other unknown reference: as today SB-V2
SB-M3 ALTER TABLE t ENABLE / DISABLE / FORCE / NO FORCE ROW LEVEL SECURITY; CREATE POLICY p ON t [AS ...] [FOR cmd] [TO ...] [USING ...] [WITH CHECK ...]; DROP POLICY [IF EXISTS] p ON t; ALTER POLICY p ON t RENAME TO q schema-neutral (no partial table); table attributes rls: {enabled, forced} (oracle pg_class.relrowsecurity, relforcerowsecurity) (T024 review: a flag is unknown in either direction where a statement the pass did not read may have changed it; SB-M9's data statements do not count) and policies: [{name, command, table}] (name and command as written, command ALL when absent; table the holding table's current name, following renames; oracle pg_policies); no claim about roles, USING or WITH CHECK a policy statement on a table the set does not hold: as an unknown reference today; other ALTER POLICY forms: schema-neutral, policy kept -
SB-M4 (T024c1b) CREATE EXTENSION [IF NOT EXISTS] x ... (top level or run by code) in a Supabase set, x one of http, vector not a statement only a superuser may run (E6 and Y51's O2.P4 refusal do not apply); the statement stays opaque (O2) and its other preconditions (O2.P4 versions, O2.P7) apply any other extension: as today (O2.P4) SB-V4
SB-M5 (T024c1b) a directory supabase/migrations without config.toml beside it, with at least one entry, every direct entry named ^([0-9]+)_(.*)\.sql$, not a sqlx set's directory a Supabase set as SB-M1, package the migrations directory any other entry (a README, a down file, a subdirectory) or a directory that cannot be listed: no set, as before SB-V3
SB-M6 (T024c1b R1) CREATE EXTENSION [IF NOT EXISTS] x [WITH] SCHEMA s at top level in a Supabase set, x one of http, vector, without VERSION, FROM or CASCADE, s not public or pg_catalog, the set (and its code) creating none of x's object names and no operator, cast, operator class or family, access method or aggregate a known effect, from the PGDG install scripts the corpus was replayed with (pgvector 0.8.7, pgsql-http 1.7): types, domains, functions, aggregates, operators, operator classes, casts and access methods in s, no relation, no implicit cast from a pg_catalog type, no polymorphic argument; the statement is not opaque, so later statements are not made uncertain any other form: opaque, as today (O2) SB-V4
SB-M7 (T024c1b R1) INSERT INTO storage.buckets ... in a Supabase set its column references are not checked (the insert succeeds); when no statement of the set or its code names buckets other than in such an insert or in REFERENCES storage.buckets (whose RI triggers fire on UPDATE and DELETE only) and none runs a dynamic EXECUTE, no trigger or rule of the set fires on it, so it is no opaque data change any other platform table, or a set that may attach a trigger or rule to storage.buckets: as today (N3.P1, opaque data change) SB-V5
SB-M8 (T024c1c) a call storage.foldername(<text>) or storage.filename(<text>) in a LANGUAGE sql body that R1b.P5's analysed form (T024c1c) reads, in a Supabase set that creates no function of that name the platform function's one signature, as the Supabase storage API's tenant migrations define it (foldername(name text) returns text[], filename(name text) returns text; supabase/storage at 132a66ae, migrations 0002, 0036, 0060, 0061), so the body's proof may use it (verification of the set's facts unchanged; the oracle's prelude stubs both with these signatures) another platform function, another argument type, a set function of the name, a sqlx set: not proven (R1b.P5, may fail) SB-V2
SB-M9 (NX-F2) INSERT, UPDATE or DELETE at top level in a Supabase set, opaque only as a data change in a set that defines code (O1), when every earlier opaque statement of the set is such a statement, every statement of the set so far was read, the statement's P12 inventory (every trigger function of the set, every routine a statement names outside its definition, closed over their calls and data changes) is bounded and holds no statement, and its target and every data target of the inventory is a table the set holds under a certain name (an unqualified pg_ name is not; a qualified name by its schema, or by public for a table created unqualified, when the pass records no other relation of the name), and (stacked gate NX-S) no CREATE [OR REPLACE] RULE came before it at top level and none is in the set's code the statement cannot change any table's row level security (PostgreSQL 17 runs only the target's and its foreign key actions' triggers, rules, defaults, constraints, index and policy expressions; event triggers fire on DDL only): rls flags and policies stay known across it; it stays opaque for every other fact any other data statement, a later one after any other opaque or unread statement, an inventory that is unbounded or holds a statement: rls unknown both ways as SB-M3; a data statement (INSERT, UPDATE, DELETE, MERGE, COPY ... FROM, WITH; SB-M7's storage.buckets insert excepted) at top level, or in the bounded inventory of any O1 statement, whose target is not such a held table (pg_catalog.pg_class, pg_policy, a view, a platform table), and an O1 statement whose inventory is unbounded: the rls flags and the policies of every held table unknown, and no later data statement is SB-M9's; (NX-S) a top-level CREATE [OR REPLACE] RULE (a rule's actions are not read; one may write pg_catalog.pg_class or pg_policy) and every data statement after it, or every data statement of a set whose code creates a rule: the same; (2026-11-18) a statement that runs code the pass cannot read (an O1 statement whose P12 inventory is unbounded: a dynamic EXECUTE, a body in another language or not lexed, a routine created by code), a top-level CREATE EVENT TRIGGER (its function runs with every later DDL statement), code of the set that creates an event trigger (from the set's start), or a file whose rest cannot be lexed: SB-M9 ends for the set, the rls flags and the policies of every table, held then or created later, unknown to its end -
SB-M10 (NX-F2) a column type (CREATE TABLE, ADD COLUMN) naming a type an SB-M6 extension created (vector, halfvec, sparsevec; http_method, content_type, http_header, http_response, http_request; their arrays), qualified by the extension's schema, or unqualified under a known search_path that reaches it (E4's value on the platform: "$user", public, extensions), when the set and its code create no type or relation of the name, no opaque statement ran since the extension and no ALTER/DROP TYPE, DOMAIN or SCHEMA names it the type exists (M2.P1 proven); modifiers per its typmod_in (pgvector 0.8.7, pgsql-http 1.7, checked live): vector, halfvec one integer 1 to 16000, sparsevec 1 to 1000000000, else refused (22023); the http types none, else refused (42601); a non-integer modifier, or one on an array written _vector, not proven any other form: M2.P1 not proven, may fail, as before SB-V2, SB-V4
SB-K1 a client receiver: a call of createClient (@supabase/supabase-js), createBrowserClient / createServerClient (@supabase/ssr), or the @supabase/auth-helpers-nextjs create*Client factories, resolved through the shared resolver; directly, through a const binding (module or function scope, imported consts included), or through one level of a function whose every return is a proven client (awaited when async) the receiver is a Supabase client; its default schema is public an options argument with a db.schema key: schema from a literal, else every site of that client goes to SB-T5; destructuring, parameters (also typed SupabaseClient), let, members: unproven -
SB-T1 <client>.from('<t>') with a string literal or bounded const, the first PostgREST verb on the chain select, insert, update, upsert or delete; (T024 review) a const builder: const q = <client>.from('<t>') (a const declared in the use's function, or both at module level, never reassigned) and a chain q.<verb>(...) in that function, read as the one chain reads_table (select) or writes_table (insert, update, upsert, delete) to the table <schema>.<t> of the package's Supabase set (tool: supabase, inferred, assumes: SB-V1); insert(...).select() is the write only a name the set does not hold as a table (a view, a table created outside the set): unknown (sql_name_unresolved); no Supabase set in the package: the package's generated types (SB-G1, T024c3; assumes: SB-V6), else unknown no_schema_source (table name in the reason); no verb on the chain and no const builder use that reads it (returned, passed on, a let): unknown builder_unread (the table in the reason; T024 review) SB-V1 (a migration set), SB-V6 (generated types)
SB-T2 <client>.schema('<s>').from('<t>')... as SB-T1 with schema s non-literal schema: unknown SB-V1 (a migration set), SB-V6 (generated types)
SB-T3 a select argument that is a string literal with embedded resources ('*, prices(*, products(*))') the base table (SB-T1); each embedded name e (alias a:e allowed, nested levels relative to their parent; (T024 review) a final join modifier !inner or !left, PostgREST's join type, leaves the resource as without it) that names a table of the set with exactly one relationship to its parent (one foreign key in either direction and no junction table joining the two): reads_table to e, verification: mapped a !hint (any other name after !, also e!hint!inner), a spread ...e, zero or several relationships, a name that is no table of the set, relationships not resolved (a set read from generated types, SB-G1): partial unknown (embedded_resource) naming the unresolved names; a non-literal select argument (T024c3): the base table and a partial unknown embedded_resource ("embedded tables not read") with the package's other tables as candidates SB-V1
SB-T4 .from(<non-literal>) on a proven client with an SB-T1 verb nothing unknown table_dynamic, candidates = the set's tables -
SB-T5 <x>.from('<lit>').<verb>(...) where <x> is not a proven client nothing unknown client_unproven (structural chain only, never a receiver-name rule) -
D .storage.from(bucket), .rpc(fn) (counted), .auth.*, .channel(...) realtime, .functions.invoke, supabase-py / supabase-dart nothing always -

Generated types (T024c3, rows SB-G; revised in T024c3, see its results):

id form claim refusal / unknown assumptions
SB-G1 a scanned .ts file whose declarations are exactly postgres-meta's typescript template output (versions 0.70.0 to 0.97.0, the generator the Supabase CLI's gen types typescript runs), compared token by token (whitespace, comments, ; and , separators and quote style ignored): first export type Json = with the generator's union; then export type Database = { or (up to 0.77) export interface Database {, an optional __InternalSupabase member, per schema exactly Tables, Views, Functions, Enums, CompositeTypes in that order ([_ in never]: never when empty); each table Row, Insert, Update (the same columns in the same order, every Update property optional, Row properties never optional; Row may end with computed fields) and Relationships; then only the generator's helpers (PublicSchema, DefaultSchema, DatabaseWithoutInternals, Tables, TablesInsert, TablesUpdate, Enums, CompositeTypes, Constants) a schema source tool: supabase_types, labelled "generated types", dialect: postgres, every fact verification: mapped: tables <schema>.<name> from Tables keys (column_set complete; constraint_set partial: the generator states no key, unique, index or check); columns from Insert, with tool_type the Row type as written and nullable from a top-level | null (unknown and any alone: unknown); a computed field listed in computed_fields, not a column; Relationships listed as written (relationships), not resolved to foreign keys (the generator names no referenced schema, and some versions leave out keys to other schemas); Views read for their shape, no records (as views of migration sets) any other shape: not a schema source (diagnostic supabase_types_unread, info, naming the line) SB-V6
SB-G2 a package (nearest package.json) with a Supabase migration set and a generated types file the migration set is the schema source; the types file is not read as one: it is compared with the set (tables; on complete migration tables also column names, nullability and relationships), each difference a supabase_types_disagreement diagnostic (info), one supabase_types_compared summary; platform schemas (SB-V2) not compared - -
D other generated forms (supabase gen types for other languages), a Database type in a file that does not start with export type Json (hand-written, Kysely) nothing always -

Precision label: an SB set with dialect postgres can join row PL-F1's statement reader only through a new row (PL-F10, Supabase migration sets), and the SB edges join PL-F9 only through its own evidence (contract test, goldens, corpus checks, review, oracle). Until then both are best_effort.

Report a problem with this pageSource: docs/contract/claims/nextjs-supabase.md