JavaScript SDK
@aurabase/aurabase-js — typed client for Node, Bun, Deno, Next.js, React, SvelteKit, Vue. Covers Database, Auth, Realtime, Storage, Functions.
One package, four managers
The SDK directly includes @aurabase/aurabase-js/ssr export for Next.js (App Router, Server Actions, Middleware), Remix, Nuxt and SvelteKit with automatic management of session cookies and anti-truncation chunking.
Create the client
Native Server-Side Rendering support
For SSR architectures (Next.js App Router, Middleware, Server Actions, SvelteKit), import createServerClient from @aurabase/aurabase-js/ssr. The user session is automatically stored in secure httpOnly cookies, with multi-chunk support for large tokens:
Codegen from your schema
npx @aurabase/gen --out lib/aurabase.types.ts (or aura db generate, which writes types.ts in the current folder) generates the types file from your complete schema (tables, views, enums, RPC functions). To plug into createClient<Database> to type all of your queries.
By service
Database
SignatureReturn
.from(table).select(cols?)``SelectBuilder<T>
.from(table).insert(row)``Promise<{ data, error }>
.from(table).update(patch)``UpdateBuilder<T>
.from(table).delete()``DeleteBuilder<T>
.rpc(fn, args)``Promise<{ data, error }>
Auth
SignatureReturn
.auth.signUp({ email, password, options? })``Promise<AuraResponse<LoginResponse>>
.auth.signInWithPassword({ email, password })``Promise<AuraResponse<LoginResponse>>
.auth.signInWithOAuth(provider, opts?) | ({ provider, ... })``Promise<AuraResponse<{ url }>>
.auth.getSession()``Promise<{ data: { session }, error }>
.auth.signOut()``Promise<AuraResponse<void>>
.auth.mfa.enroll() | .auth.mfaEnroll()``Promise<AuraResponse<MfaEnrollResponse>>
Realtime
SignatureReturn
.channel(name, config?)``Channel
channel.on(event, filter, cb)``Channel
channel.subscribe()``Channel
channel.send({ type, event, payload })``Promise<void>
channel.unsubscribe()``Promise<void>
Storage
SignatureReturn
.storage.from(bucket).upload(path, file, opts?)``Promise<{ data, error }>
.storage.from(bucket).download(path)``Promise<Blob>
.storage.from(bucket).getPublicUrl(path, opts?)``{ publicUrl }
.storage.from(bucket).createSignedUrl(path, expiresIn)``Promise<{ signedUrl }>
.storage.from(bucket).remove(paths[])``Promise<{ data, error }>
Functions
SignatureReturn
.functions.invoke(name, { body?, method?, path?, headers?, responseType?, signal?, timeout? })``Promise<{ data, error }>
.functions.list()``Promise<{ data: FunctionDef[], error }>
.functions.get(nameOrId)``Promise<{ data: FunctionDef, error }>
.functions.listJobs({ status?, limit? })``Promise<{ data: Job[], error }>
.functions.getJob(jobId)``Promise<{ data: Job, error }>
.functions.enqueueJob(functionName, { payload?, delaySecs?, maxAttempts? })``Promise<{ data: Job, error }>
.functions.listCronJobs()``Promise<{ data: CronJob[], error }>
.functions.createCronJob(name, schedule, functionName, { payload? })``Promise<{ data: CronJob, error }>
.functions.deleteCronJob(name)``Promise<{ data, error }>
Only invoke is open to the public (anon) key. list, get, listJobs, getJob, enqueueJob, listCronJobs, createCronJob and deleteCronJob require a service_role key and belong on your server: a FunctionDef carries the function's source code and environment variables, so these calls answer 403 to a public key. invoke reports errors as FunctionsHttpError (the function answered with an error, any status) or FunctionsRelayError (the platform failed: network, 502, 503, 504), both exported by @aurabase/aurabase-js.
Uniform shape { data, error }
Each async method returns { data, error }. error is null on success, otherwise an object with code, message, details.