Naming
The names better-supabase uses for definitions, instances, files, types and block names, and the renames from earlier versions.
Every app has one definition and one runtime instance per side. The docs,
the examples and the files better-supabase init writes all use the same
names, so code copied from one place works in another.
Glossary
Each concept has one name. The renames land in phases listed on the roadmap; until a phase ships, the code still exports the name in the Replaces column, and each phase ships a codemod for its renames. ADR 0093 records the decision.
| Term | Meaning | Replaces |
|---|---|---|
| block | the unit you install: tables, functions, a client and generated code | module, SQL module, kit |
| core block | a block installed once per project (memberships, permissions, outbox, queue, audit) | foundation block |
| instance | one named install of a block, with its own tables | nothing |
| record type | a kind of row other blocks attach to (RecordRef, config subjects) | subject, SubjectRef |
| names | the nouns an instance uses (blocks.<name>.names) | entities |
| tables | the app's own tables (SQL in supabase/schemas) | tables |
| tenant | the account that owns data, in every library name (auth.tenant, requireTenant) | organization (0.15 to 0.31) |
| organization | what the examples and the organizations block call a tenant in the UI and its tables | nothing |
| preset | a named selection of blocks | nothing |
| design | the JSON document Create writes, the one format for presets | preset codes |
| registry item | an installable file: a page, widget, route or recipe | screens, glue |
| provider | a versioned interface your app implements (ShippingProvider) | carrier, backend |
| adapter | a framework integration (config adapters) | integration, bridge |
| plugin | the versioned repository extension interface for third parties | the built-in plugins |
| controller | headless state for a widget or a list | nothing |
| hook | a framework wrapper around a controller or a query | nothing |
| engine | what runs the hooks: TanStack Query, the controllers, PowerSync, TanStack DB, SQLite | separate client data layers |
| client | the one better-supabase client, named bsb; instances and tables are properties on it | bs, transport |
| callbacks | the before_* and after_* functions of a block (blocks.<name>.callbacks) | block hooks |
| owner | who owns a row: tenant, user or none (blocks.<name>.scope) | mode |
| event | an outbox CloudEvent; in-process on handlers are listeners | nothing |
| automation | a trigger and actions an organization can edit | rules, flows |
| workflow | code that runs durably | nothing |
| schedule | a timer on the queue | reminders, SLA and sequence timers |
The data verbs are the same on every table and every instance: list,
page, get, count and aggregate read; create, update, upsert
and delete write; attach and detach link a row to a record. "Feature"
only means a feature flag. SQL functions follow the same verbs: create_*
inserts, upsert_* inserts or updates by a key, update_* and delete_*
change one row, and set_* replaces one field or one child set. The old
save_*, add_* and remove_* spellings are upsert_*, create_* and
delete_*.
Definition and instances
betterSupabase is the definition from createSupabase. It holds the schema
and the configuration, no secrets, and is safe to import anywhere.
bsb is the runtime instance an adapter creates from it: createNext,
createServer, createClient, createHono, createOrpc, createEdge or
createMcp. Each file that creates one exports it as bsb, so a call reads
the same in every framework:
const { db } = await bsb.context(); // Next.js Server Component
app.use("/api/*", bsb.middleware()); // Hono
Deno.serve(bsb.handler(fn)); // Edge FunctionFiles
The definition and the instances live in lib/supabase/, the layout
Supabase uses for its own utils/supabase/server.ts and client.ts:
| File | Exports | Runs on |
|---|---|---|
lib/supabase/index.ts | betterSupabase | both, imported as @/lib/supabase |
lib/supabase/server.ts | bsb | the server; Next.js adds import "server-only" |
lib/supabase/client.ts | bsb | the browser |
lib/supabase/generated.ts | schema | both, written by better-supabase gen |
Hono and oRPC starters create bsb in the app's entry (src/server.ts,
src/router.ts), which only runs on the server. Edge Functions import the
definition from supabase/functions/_shared/supabase.ts and create bsb in
the function's own server.ts.
Types
- The adapter factories return
Better<Adapter>:createNextreturnsBetterNext,createClientreturnsBetterClient,createPostgresreturnsBetterPostgres,createQueriesreturnsBetterQueries. - Options are
<Thing>Options:ClientOptions,SupabaseOptions,QueriesOptions,MiddlewareOptions. - Acronyms in names are written as words:
toOrpcError,createOpenApi. - Members that sit next to your table names start with
$so a table can't shadow them:db.$table(name),repository.$tableName,queries.$key.
Supabase's own cookie and header names keep their sb- prefix
(sb-<project>-auth-token); those belong to @supabase/ssr, not to the
library.
Block names
Every block names its entities, tables, permission keys, events, hint codes
and functions by one convention, so you can guess a name from the block and
the noun.
ADR 0130
records the decision. 0.46 renamed the permission keys and 0.47 the entity
keys, subject types, hint codes, functions and event types. 0.47 also renamed the module
tables (work_items becomes tasks, rules becomes automations): the
upgrade migration renames each table with its indexes, policies and
constraints, so no row moves. The foreign key columns that point at a task or
an activity (work_item_id, activity_id) become task_id and
activity_id the same way.
- Block names are kebab-case. Existing block names do not change.
- An entity key equals its
singular. Entity keys are unique across all blocks. When the noun is generic (document,request,entry,policy,task,type,location,key,link,view,field,node,server,snapshot,definition,project) or another block uses it, the block noun comes first:knowledge_document,leave_request,drive_node. The block that owns the plain noun keeps it (documentskeepsdocument,taskskeepstaskandproject). - A table is the plural of its entity in snake*case (
compliance_policybecomescompliance_policies). A table that is not an entity (a link, log or history table) starts with its entity's singular:task_assignees,case_actions. Uncountable nouns stay singular:control_evidence,webhook_inbox,subject_user_state,chat_state_cache,scim_sync_log,ai_message_feedback,ai_model_catalog,attachment_cleanup,custom_emoji. Acronym prefixes of a standard stay (ssf*\_,scim\_\_,oauth\_\*). subjectis the SQL term andrecordis the docs term. The columnssubject_typeandsubject_id, thesubjectsblock and thesubject.*events keep their names.- A permission key is
<area>.<verb>, where the area is the block name in snake_case. Exceptions:messaging,commentsandchannelssharemessages.*because they share one table (channelskeepschannels.*for channel settings);organizationsownsorganization.*,members.*andplatform.*;platform.*stays for platform-wide actions. - The permission verbs are
read(see),write(create and change records),delete(only when deleting differs from writing),manage(configure the block, act on everyone's records), and domain verbs (approve,submit,review,acknowledge,collect,assign,grant,assess,close,invite,record). There is noview,editoradmin, and a key never has three parts:custom_fields.read_sensitive, notcustom_fields.read_sensitive. - An event type is
<entity singular>.<past tense verb>, where the entity is the one that changed, whichever block wrote it. The lifecycle verbs arecreated,updated,deleted,archived,restoredandpurged. No event is namedsaved(it iscreatedorupdated),removed(it isdeleted),edited(it isupdated),canceled(it iscancelled),upsertedor<attribute>_set(it is<attribute>_changed). A record that belongs to another one, such as a member, a role or an entry, may use the pair<child>_addedand<child>_removedon its parent. The verbs that end a record keep their own meaning:cancelled(stopped before it took effect),voided(an issued document made invalid and kept),closed(finished and reopenable),withdrawn(taken back by whoever submitted it),revoked(taken back by whoever granted it) andrejected(refused by a reviewer).check:namingrejects the synonymsaborted,abandoned,dismissed,discarded,deactivated,invalidated,finished,stoppedandterminated; two events keep a domain verb on purpose (lease.terminated,medication_order.stopped). Payload keys are camelCase and carryorganizationIdwhen the event has a tenant. - A hint code is
<ENTITY>_<REASON>in upper snake case, from the entity singular:CONTROL_FORBIDDEN,TASK_NOT_FOUND. The prefix is a run of the block's name words, such asAI_EVAL_forai-evals, or the noun of one of its entities. Codes of a shared core (ACTOR_,CREDENTIAL_,IMPORT_ITEM_,NUMBER_) keep their prefix in every block. - SQL functions take the entity singular:
create_<entity>,update_<entity>,get_<entity>,list_<entities>,delete_<entity>, and domain verbs (close_case,assess_risk). Hooks arebefore_<entity>_<action>andafter_<entity>_<action>. - Exports are
create<Pascal>,<camel>Blockand<camel>Events, with acronyms written as words:createOauthServer. - A block's docs page is titled with its plain name in title case,
sometimes with a short qualifier ("Audits and inspections", "Usage and
quotas"), and its first sentence names the block by its block name. The
URL is
/docs/blocks/<block-name>. - The manifest's
categorydecides which docs folder the page sits in.
When you rename a block's nouns with blocks.<name>.names, its tables,
functions, events and permission keys follow the new singular; see
Typed blocks.
Verbs
A name says what a function does with its first word, and the verb is the same in TypeScript, in generated code and in SQL.
| Verb | Meaning |
|---|---|
get | reads one thing or a list from a source (a database, a file, the environment) |
use | a hook |
create, update, upsert, delete | writes, in repositories, actions and SQL functions |
There is no load, fetch or read verb in an exported function name, and no
loaded in data code. pnpm check:naming fails on one unless
api/naming.json lists it under verbs with its reason. The names that stay are
factories around fetch, parsers that compute from their argument, and names
that are concepts, such as read sets. The block record binding member that was
load is get, so bsb.record(...).load(id) is bsb.record(...).get(id).
ADR 1250
records the decision.
Renames
packages/better-supabase/api/naming.json is the source of truth for names.
It holds the rules and the rename table below, and
ADR 0246
records the decision. pnpm check:naming fails when a renamed name returns or
when code breaks a rule, and the old names have no alias. Run
better-supabase codemod naming to rename them in your
app, and better-supabase doctor (BS260) to find the ones left.
| Kind | Old | New | Since |
|---|---|---|---|
| env | AUTH_HOOK_SECRET | BETTER_SUPABASE_AUTH_HOOK_SECRET | 0.54 |
| env | BEFORE_USER_CREATED_SECRET | BETTER_SUPABASE_BEFORE_USER_CREATED_SECRET | 0.54 |
| env | BSB_CLOUD_URL | BETTER_SUPABASE_CLOUD_URL | 0.54 |
| env | BSB_STACK | BETTER_SUPABASE_STACK | 0.54 |
| function | buildJsonSchema | toJsonSchema | 0.54 |
| function | buildApiModel | defineApiModel | 0.54 |
| function | createRuleSink | automationSink | 0.54 |
| function | taskRecurrenceSink | taskRecurrenceSink | 0.54 |
| type | SessionEntryConfig | SessionEntryOptions | 0.54 |
| type | GuardEntryConfig | GuardEntryOptions | 0.54 |
| subpath | ai-sdk/workflow/react | ai-sdk/workflow-react | 0.54 |
| type | ChainProofFailure | ChainProofError | 0.54 |
| type | ParseScaledFailure | ParseScaledError | 0.54 |
| type | RefreshFailure | RefreshError | 0.54 |
| type | StorageFailure | StorageError | 0.54 |
| type | SvelteKitFailure | SvelteKitError | 0.54 |
| type | TelemetryFailure | TelemetryError | 0.54 |
| type | XhrFailure | XhrError | 0.54 |
| type | AgentPassthroughSettings | AgentPassthroughOptions | 0.54 |
| hint | APPEND_ONLY | TABLE_APPEND_ONLY | 0.54 |
| hint | CHAIN_SIGNER | AUDIT_CHAIN_SIGNER | 0.54 |
| hint | FISCAL_YEAR_CLOSED | PERIOD_CLOSED | 0.54 |
| function | bsb.uid(), bsb.owns(uuid) | better_supabase.uid(), better_supabase.owns(uuid) | 0.54 |
Blocks, events and hint prefixes renamed in 0.66 (ADR 0699). A block has one
key: blocks.webhooks and blocks["incoming-webhooks"] replace the SQL
module names webhooks-out and webhooks-in, and codemod naming rewrites
the config key.
| Kind | Old | New | Since |
|---|---|---|---|
| block | webhooks-out | webhooks | 0.66 |
| block | webhooks-in | incoming-webhooks | 0.66 |
| event | message.edited | message.updated | 0.66 |
| event | drive_node.document_saved | drive_node.document_updated | 0.66 |
| hint | EVAL_* | AI_EVAL_* | 0.66 |
| hint | HOSTNAME_* | DOMAIN_* | 0.66 |
| hint | SUPPORT_* (impersonation) | IMPERSONATION_* | 0.66 |
| hint | CARE_* (clinical-decision-support) | DECISION_SUPPORT_* | 0.66 |
| hint | BOM_* | MANUFACTURING_BOM_* | 0.66 |
| hint | SSF_* | SECURITY_EVENT_* | 0.66 |
| hint | TIMESHEET_* | TIME_ENTRIES_TIMESHEET_* | 0.66 |
| hint | FIELD_* (custom-fields) | CUSTOM_FIELD_* | 0.66 |
| hint | PRESCRIPTION_* | E_PRESCRIBING_* | 0.66 |
| hint | WEBHOOK_IN_* | INCOMING_WEBHOOK_* | 0.66 |
0.67 reads session cookies through @supabase/ssr (ADR 0847). The renamed
function returns a promise, so codemod naming renames the call and you add
the await.
| Kind | Old | New | Since |
|---|---|---|---|
| function | readSession | ssrSession | 0.67 |
| function | loadBindings | getBindings | 0.88 |
| function | loadConfig | getConfig | 0.88 |
| function | loadEnv | getEnv | 0.88 |
| function | loadJsonPath | getJsonPath | 0.88 |
| function | loadMyWork | getMyWork | 0.88 |
| function | loadProject | getProject | 0.88 |
| function | loadSnapshot | getSnapshot | 0.88 |
| function | loadTimeline | getTimeline | 0.88 |
| function | readArgSource | getArgSource | 0.88 |
| function | readArgSqlType | getArgSqlType | 0.88 |
| function | readBitstringStatus | getBitstringStatus | 0.88 |
| function | readC2paManifest | getC2paManifest | 0.88 |
| function | readCatalog | getCatalog | 0.88 |
| function | readDesignFile | getDesignFile | 0.88 |
| function | readGrants | getGrants | 0.88 |
| function | readPolicies | getPolicies | 0.88 |
| function | readRulePolicies | getRulePolicies | 0.88 |
| function | readSecurityCatalog | getSecurityCatalog | 0.88 |
| function | readStatus | getStatus | 0.88 |
| function | tableLoaders | tableGetters | 0.88 |
| function | loadFunctions | getFunctions | 0.88 |
Columns renamed in 0.66, so timestamps end in _at and a user reference
names the user's role. better-supabase upgrade renames them in place
(alter table ... rename column), so no row moves. The functions keep their
parameter names (period_start, period_end) and the support session rows
keep the target_user_id key, which targetUserId in TypeScript reads.
| Table | Old | New | Since |
|---|---|---|---|
marketplace_invoices, marketplace_meter_reports, billing_native_subscriptions | period_start | period_starts_at | 0.66 |
marketplace_invoices, marketplace_meter_reports, billing_native_subscriptions, billing_subscriptions | period_end | period_ends_at | 0.66 |
support_sessions, support_requests | target_user_id | target_id | 0.66 |
The rules:
- Environment variables the library or CLI reads start with
BETTER_SUPABASE_. The platform's own names (SUPABASE_*,NEXT_PUBLIC_*,EXPO_PUBLIC_*,PUBLIC_*,VERCEL_*,DATABASE_URL) keep theirs. - An exported type ends in
Options,Config,DecisionorError, never inSettings,ArgsorFailure.naming.jsonkeeps an allowlist for a violation that is not renamed yet, and the check fails when a listed name stops violating. The type list is empty. - A hint code is
<ENTITY>_<REASON>, and a core hint carries its core noun (AUDIT_CHAIN_SIGNER,TABLE_APPEND_ONLY,PERIOD_CLOSED).check:namingfails on a code whose prefix neither the block's name nor an allowlisted entity noun gives, and on an event verb the rules ban. Both lists only shrink. - The helper functions live in
better_supabase. Thebsbschema is gone. - Reads are
get*, neverload*,fetch*orread*(ADR 1250). - Doctor codes are
BSand three digits, never lower case. - A subpath is
better-supabase/<area>orbetter-supabase/<area>/<variant>.
Last updated on