docs › Référence › SDK JavaScript SDK JavaScript @aurabase/client — client typé pour Node, Bun, Deno, Next.js, React, SvelteKit, Vue. Couvre Database, Auth, Realtime, Storage, Functions.
10 min de lecture· Niveau référence· Révisé le 15 avr. 2026
# Installation
Un package, quatre managers § 01 pnpm npm yarn bun
terminal BASH copy
pnpm add @aurabase/client
Astuce
Packages compagnons : @aurabase/next (helpers server/action + middleware), @aurabase/react (hooks typés + SWR-style), @aurabase/sveltekit, @aurabase/expo.
# Initialisation
Créer le client § 02 src/lib/aurabase.ts
TYPESCRIPT copy
import { createClient } from '@aurabase/client'
import type { Database } from './aurabase.types'
export const aura = createClient < Database > (
process. env . AURA_URL !,
process. env . AURA_ANON_KEY !,
{ auth: { persistSession: true , autoRefreshToken: true } }
)
# Types
Codegen depuis votre schéma § 03 aura types gen génère un fichier aurabase.types.ts avec l'intégralité de votre schéma : tables, vues, fonctions, relations. À brancher dans createClient<Database>pour typer l'ensemble du SDK.
{
"scripts" : {
"types:gen" : "aura types gen > src/aurabase.types.ts" ,
"migrate" : "aura db push && pnpm types:gen"
}
}
Signature Retour
.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 }>
Signature Retour
.auth.signUp({ email, password })Promise<AuthResponse>
.auth.signInWithPassword({ ... })Promise<AuthResponse>
.auth.signInWithOAuth({ provider })Promise<{ url }>
.auth.getSession()Promise<Session | null>
.auth.signOut()Promise<void>
.auth.mfa.enroll({ factor_type })Promise<Factor>
Signature Retour
.channel(name, config?)Channel
channel.on(event, filter, cb)Channel
channel.subscribe()Channel
channel.send({ type, event, payload })Promise<void>
channel.unsubscribe()Promise<void>
Signature Retour
.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 }>
Signature Retour
.functions.invoke(name, { body?, headers? })Promise<{ data, error }>
Chaque méthode async retourne { data, error }. error est null en cas de succès, sinon un objet avec code, message, details.
const { data, error } = await aura. from ( 'users' ). select (
'*' ). single ()
if (error) {
if (error. code === 'PGRST116' ) notFound ()
throw new AurabaseError (error)
}
# Continuer
Pour aller plus loin § 06 Dernière mise à jour · 15 avr. 2026