Skip to content
Aurabase Logo
aurabase

Client and services

The entry point of the SDK: how to create the client and which services it exposes.

Reference6 min readLevel reference

Exported functions#

FunctionDescription
function createClient<Database = any>(baseUrl: string, apiKey: string, options?: AuraClientOptions): AuraClient<Database>Create a new Aurabase client instance.
function createAdminClient<Database = any>(baseUrl: string, serviceRoleKey: string, options?: AuraClientOptions): AuraClient<Database>Creates a client for SERVER use only for administration operations (client.authAdmin: list/create/ban users, read audit).

AuraClient#

PropertyDescription
readonly baseUrl: stringProject URL (https://<slug>.aurabase.dev), without trailing bar.
readonly apiKey: string | nullProject API key (anon or service_role) sent in the apikey header; null if none was provided.
readonly fetchFn: typeof globalThis.fetchFunction fetch used for all queries (that of options.fetch, otherwise globalThis.fetch).
readonly authStore: BaseAuthStoreSession store (access token, refresh token, user): memory, localStorage or cookies depending on context.
readonly retryConfig: { enabled: boolean; maxRetries: number; }Read request resumption policy (GET, HEAD) on transient error: enabled or not, and maximum number of resumptions.
readonly requestTimeoutMs?: numberDefault timeout (ms) for JSON requests without signal. undefined → core fault (30s).
readonly onEvent?: (event: AuraObservabilityEvent) => voidObservability hook — see AuraClientOptions.onEvent.
readonly debug?: booleanJournalise chaque AuraObservabilityEvent via console.debug — voir AuraClientOptions.debug.
readonly parseBigIntAsString?: booleanPreserves PostgreSQL 64-bit bigint values as strings instead of JSON numbers when enabled.
get auth(): AuthServiceAuthentication service: registration, connection, session, MFA, OAuth, identities.
get authAdmin(): AuthAdminServiceAuthentication administration API (users, sessions, audit log, email templates).
get db(): DatabaseService<Database, Schema>Database service: queries on tables and views, SQL function calls (rpc), raw SQL.
get nosql(): NoSqlServiceNoSQL service (MongoDB): collections, document queries and aggregation pipelines (aggregate).
get storage(): StorageServiceStorage service: buckets, sending, downloading, signed and public URLs, image transformations.
get realtime(): RealtimeServiceReal-time service: channels, Postgres changes, broadcast (broadcast) and presence.
get functions(): FunctionsServiceEdge Functions service: invocation, and management of jobs and cron with a service_role key.
get ai(): AiServiceAI service: conversation (chat), embeddings, RAG (ingest, queries, namespaces), semantic search and sessions.
get notifications(): NotificationsServiceNotifications service: sending (email, SMS, push, webhook), history, templates and administration.
MethodDescription
dispose(): voidDismounts the client: stops proactive refresh (ticker + visibility + BroadcastChannel), disconnects realtime, empties auth listeners.
from<TableName extends string & ValidRelationKeys<Schema['Tables']>, Table extends Schema['Tables'][TableName]>(table: TableName): AuraQueryBuilder<Schema, Table, TableName, AuraClientOptionsT>
from<ViewName extends string & ValidRelationKeys<Schema['Views']>, View extends Schema['Views'][ViewName]>(view: ViewName): AuraQueryBuilder<Schema, View, ViewName, AuraClientOptionsT>
Shortcut: query a database table or view (Supabase-compatible API).
rpc<FnName extends string = string, Args extends Record<string, unknown> = Record<string, unknown>>(fn: FnName, args?: Args, options?: Parameters<DatabaseService<Database, Schema>['rpc']>[2]): ReturnType<DatabaseService<Database, Schema>['rpc']>Shortcut: call a stored procedure / PostgreSQL function via RPC (Supabase-compatible API).
channel(name: string, options?: ChannelConfig): AuraChannelShortcut: create a realtime channel with Supabase-compatible API.
removeChannel(channel: string | AuraChannel): voidShortcut: remove a realtime channel by name or AuraChannel instance.
removeAllChannels(): voidShortcut: remove all realtime channels and unsubscribe.
getChannels(): AuraChannel[]Shortcut: list all active realtime channels.
Generated page

This page is generated from the type declarations and comments of the SDK, so it cannot drift from the published code. For worked examples, read the guides.

@aurabase/aurabase-js@0.7.5 · aura@0.3.4↗ Report a problem