@linabase/js

SDK Reference

Auto-generated from the source of @linabase/js. For a guided introduction, see the main documentation.

Classes

AuthClient

class

Authentication API for a Linabase project. Exposed via `linabase.auth` on the client returned by `createClient`. Handles sign-up, sign-in (password / magic-link / OAuth), session management, and — when called with a service-role key — server-side admin operations under `auth.admin`. Sessions are persisted in the configured storage (defaults to localStorage in the browser, in-memory in Node). The current access token is automatically attached to every database, storage, and function request.

Examples

const { data, error } = await linabase.auth.signInWithPassword({
  email: "alice@example.com",
  password: "correct horse battery staple",
});

linabase.auth.onAuthStateChange((event, session) => {
  console.log(event, session?.user.email);
});

onSessionChange

property

Callback that the parent LinabaseClient can set to update the Authorization header when the user signs in/out or a token is refreshed.

(session: AuthSession | null) => void | null

admin

accessor

mfa

accessor

getSession

method

Return the current persisted session. Auto-refreshes if the access token is expired and a refresh token is available. Returns `{ session: null }` when the user isn't signed in.

() => Promise<{ data: { session: AuthSession | null }; error: any }>

Returns

Promise<{ data: { session: AuthSession | null }; error: any }>

Examples

const { data: { session } } = await linabase.auth.getSession();
if (session) console.log("Signed in as", session.user.email);

getUser

method

Fetch the current user.

(jwt?: string) => Promise<{ data: { user: AuthUser | null }; error: any }>

Parameters

  • jwt?: stringOptional access token to use instead of the stored session. Useful for validating a JWT without installing it as the active session (e.g. admin tooling, custom auth bridges).

Returns

Promise<{ data: { user: AuthUser | null }; error: any }>

onAuthStateChange

method
(callback: (event: string, session: AuthSession | null) => void) => { unsubscribe: () => void }

Parameters

  • callback: (event: string, session: AuthSession | null) => void

Returns

{ unsubscribe: () => void }

refreshSession

method
() => Promise<{ data: AuthSession | null; error: any }>

Returns

Promise<{ data: AuthSession | null; error: any }>

resetPasswordForEmail

method
(email: string, _options?: { redirectTo?: string }) => Promise<{ error: any }>

Parameters

  • email: string
  • _options?: { redirectTo?: string }

Returns

Promise<{ error: any }>

setSession

method

Set (or clear) the current session. Three valid shapes: - `null` — clear the session. - Full `AuthSession` — restore a persisted session (e.g. from AsyncStorage). Auto-refreshes if the token is already expired. - `{ access_token, refresh_token, ... }` — token-only, Supabase v2 pattern. Used by OAuth / magic-link callbacks that only have tokens in the URL hash and no user object. The SDK installs the tokens, fetches `/auth/v1/user`, and emits SIGNED_IN. Returns a promise that resolves once the user is populated (or rejects if the token is invalid). Internal callers (signIn, signUp, etc.) pass `_internal=true` to skip the INITIAL_SESSION / SIGNED_IN emit since they emit their own lifecycle events.

(session: AuthSession | SetSessionTokens | null, _internal?: boolean) => void | Promise<{ data: AuthSession | null; error: any }>

Parameters

  • session: AuthSession | SetSessionTokens | null
  • _internal?: boolean

Returns

void | Promise<{ data: AuthSession | null; error: any }>

signIn

method

Sign in an existing user with email + password. Alias of signInWithPassword. On success, the session is persisted and subsequent SDK calls use the returned access token automatically.

(params: { email: string; password: string }) => Promise<{ data: AuthSession | null; error: any }>

Parameters

  • params: { email: string; password: string }

Returns

Promise<{ data: AuthSession | null; error: any }>

Examples

const { data, error } = await linabase.auth.signIn({
  email: "alice@example.com",
  password: "correct horse battery staple",
});
if (error) console.error(error.message);

signInWithIdToken

method
(params: { nonce?: string; provider: OAuthProvider; token: string }) => Promise<{ data: AuthSession | null; error: any }>

Parameters

  • params: { nonce?: string; provider: OAuthProvider; token: string }

Returns

Promise<{ data: AuthSession | null; error: any }>

signInWithOAuth

method
(params: { provider: OAuthProvider; redirectTo?: string }) => { url: string }

Parameters

  • params: { provider: OAuthProvider; redirectTo?: string }

Returns

{ url: string }

signInWithOtp

method
(params: { email: string; options?: { emailRedirectTo?: string } }) => Promise<{ data: any; error: any }>

Parameters

  • params: { email: string; options?: { emailRedirectTo?: string } }

Returns

Promise<{ data: any; error: any }>

signInWithPassword

method

Supabase-compatible alias for signIn

(params: { email: string; password: string }) => Promise<{ data: AuthSession | null; error: any }>

Parameters

  • params: { email: string; password: string }

Returns

Promise<{ data: AuthSession | null; error: any }>

signOut

method

Sign the current user out, clear the persisted session, and revoke the refresh token on the server. Fires a `SIGNED_OUT` event to listeners registered with `onAuthStateChange`.

() => Promise<{ error: any }>

Returns

Promise<{ error: any }>

Examples

await linabase.auth.signOut();

signUp

method

Create a new user account with email + password. On success, the user is signed in and the session is persisted. Pass extra metadata via `data`; it is stored on the user record and available later as `user.user_metadata`.

(params: { data?: Record<string, unknown>; email: string; password: string }) => Promise<{ data: AuthSession | null; error: any }>

Parameters

  • params: { data?: Record<string, unknown>; email: string; password: string }

Returns

Promise<{ data: AuthSession | null; error: any }>

Examples

const { data, error } = await linabase.auth.signUp({
  email: "alice@example.com",
  password: "correct horse battery staple",
  data: { full_name: "Alice" },
});

updatePassword

method
(newPassword: string) => Promise<{ error: any }>

Parameters

  • newPassword: string

Returns

Promise<{ error: any }>

updateUser

method
(attributes: { data?: Record<string, any>; email?: string; password?: string }) => Promise<{ data: { user: AuthUser | null }; error: any }>

Parameters

  • attributes: { data?: Record<string, any>; email?: string; password?: string }

Returns

Promise<{ data: { user: AuthUser | null }; error: any }>

verifyOtp

method
(params: { email?: string; phone?: string; token: string; type?: "email" | "sms" | "magiclink" | "signup" | "recovery" }) => Promise<{ data: any; error: any }>

Parameters

  • params: { email?: string; phone?: string; token: string; type?: "email" | "sms" | "magiclink" | "signup" | "recovery" }

Returns

Promise<{ data: any; error: any }>

BucketClient

class

Operations against a single storage bucket: upload, download, list, delete, signed URLs, public URLs, move, and copy. Created by `linabase.storage.from(bucketName)`. Most file paths inside a bucket are arbitrary keys; common conventions are `userId/filename.ext` or `category/asset.ext`.

Examples

const bucket = linabase.storage.from("avatars");

await bucket.upload(`${user.id}/avatar.png`, file, { upsert: true });

// Public bucket: anyone can fetch the URL.
const { data: { publicUrl } } = bucket.getPublicUrl(`${user.id}/avatar.png`);

// Private bucket: time-limited URL.
const { data } = await bucket.createSignedUrl(`${user.id}/report.pdf`, 3600);

copy

method
(fromPath: string, toPath: string) => Promise<{ error: any }>

Parameters

  • fromPath: string
  • toPath: string

Returns

Promise<{ error: any }>

createSignedUploadUrl

method
(path: string) => Promise<{ data: { path: string; signedUrl: string; token: string } | null; error: any }>

Parameters

  • path: string

Returns

Promise<{ data: { path: string; signedUrl: string; token: string } | null; error: any }>

createSignedUrl

method

Generate a time-limited signed URL for a private object. Valid for `expiresIn` seconds.

(path: string, expiresIn: number) => Promise<{ data: { signedUrl: string } | null; error: any }>

Parameters

  • path: string
  • expiresIn: number

Returns

Promise<{ data: { signedUrl: string } | null; error: any }>

Examples

const { data } = await linabase.storage
  .from("docs")
  .createSignedUrl(`${userId}/report.pdf`, 3600);
if (data) window.open(data.signedUrl);

createSignedUrls

method
(paths: string[], expiresIn: number) => Promise<{ data: { path: string; signedUrl: string }[] | null; error: any }>

Parameters

  • paths: string[]
  • expiresIn: number

Returns

Promise<{ data: { path: string; signedUrl: string }[] | null; error: any }>

download

method

Download an object as a `Blob`.

(path: string) => Promise<{ data: Blob | null; error: any }>

Parameters

  • path: string

Returns

Promise<{ data: Blob | null; error: any }>

Examples

const { data } = await linabase.storage.from("docs").download("file.pdf");
if (data) {
  const url = URL.createObjectURL(data);
  window.open(url);
}

getPublicUrl

method

Build a public URL for an object in a public bucket. No request is made; this just constructs the URL synchronously. For private buckets, use createSignedUrl instead.

(path: string, options?: { transform?: { format?: string; height?: number; quality?: number; width?: number } }) => { data: { publicUrl: string } }

Parameters

  • path: string
  • options?: { transform?: { format?: string; height?: number; quality?: number; width?: number } }

Returns

{ data: { publicUrl: string } }

Examples

const { data: { publicUrl } } = linabase.storage
  .from("avatars")
  .getPublicUrl(`${userId}/avatar.png`, { transform: { width: 64, height: 64 } });

list

method
(prefix?: string) => Promise<{ data: any[]; error: any }>

Parameters

  • prefix?: string

Returns

Promise<{ data: any[]; error: any }>

move

method
(fromPath: string, toPath: string) => Promise<{ error: any }>

Parameters

  • fromPath: string
  • toPath: string

Returns

Promise<{ error: any }>

remove

method
(pathOrPaths: string | string[]) => Promise<{ data: any; error: any }>

Parameters

  • pathOrPaths: string | string[]

Returns

Promise<{ data: any; error: any }>

upload

method

Upload a file to the bucket at the given path.

(path: string, file: Blob | File | ArrayBuffer, options?: { contentType?: string; headers?: Record<string, string>; upsert?: boolean }) => Promise<{ data: any; error: any }>

Parameters

  • path: stringObject key inside the bucket (e.g. `userId/avatar.png`).
  • file: Blob | File | ArrayBufferFile contents as `Blob`, `File`, or `ArrayBuffer`.
  • options?: { contentType?: string; headers?: Record<string, string>; upsert?: boolean }

Returns

Promise<{ data: any; error: any }>

Examples

const file = e.target.files![0];
await linabase.storage
  .from("avatars")
  .upload(`${userId}/avatar.png`, file, { upsert: true });

DatabaseClient

class

Chainable query builder for a Postgres table. Created by `linabase.from(table)`. Every chained method returns the same client so you can keep adding filters, modifiers, and projections. Awaiting the chain (or calling a terminal method like `.single()` or `.csv()`) sends the request. Queries respect row-level security: signed-in users see only the rows their RLS policies allow.

Examples

const { data, error } = await linabase
  .from("posts")
  .select("id, title, author:profiles(name)")
  .eq("published", true)
  .order("created_at", { ascending: false })
  .limit(20);
await linabase
  .from("posts")
  .insert({ title: "Hello", body: "World" });
const { data } = await linabase
  .from("posts")
  .update({ title: "Edited" })
  .eq("id", 42)
  .select();

abortSignal

method

Pass an AbortSignal for request cancellation.

(signal: AbortSignal) => this

Parameters

  • signal: AbortSignal

Returns

this

and

method

AND filter: and("age.gt.20,name.eq.John")

(filters: string, options?: { foreignTable?: string }) => this

Parameters

  • filters: string
  • options?: { foreignTable?: string }

Returns

this

containedBy

method

Contained by (<@)

(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

contains

method

Contains (@>) - array or JSONB containment

(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

count

method

Request exact, estimated, or planned count via Prefer header

(type: "exact" | "estimated" | "planned") => this

Parameters

  • type: "exact" | "estimated" | "planned"

Returns

this

csv

method

Request CSV format. Returns raw CSV text in data instead of parsed objects.

() => this

Returns

this

delete

method

Delete rows that match the active filters. **Always** combine with at least one filter (e.g. `.eq("id", x)`) — calling `.delete()` on a bare builder removes every row in the table.

(options?: { count?: "exact" | "estimated" | "planned" }) => this

Parameters

  • options?: { count?: "exact" | "estimated" | "planned" }

Returns

this

Examples

await linabase
  .from("posts")
  .delete()
  .eq("id", 42);

eq

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

execute

method
() => Promise<QueryResult<any> | SingleQueryResult<any> | CsvQueryResult>

Returns

Promise<QueryResult<any> | SingleQueryResult<any> | CsvQueryResult>

explain

method

Get the query execution plan (EXPLAIN).

(options?: { analyze?: boolean; buffers?: boolean; format?: "json" | "text"; settings?: boolean; verbose?: boolean; wal?: boolean }) => this

Parameters

  • options?: { analyze?: boolean; buffers?: boolean; format?: "json" | "text"; settings?: boolean; verbose?: boolean; wal?: boolean }

Returns

this

filter

method

Generic filter: filter("column", "operator", "value")

(column: string, operator: string, value: any) => this

Parameters

  • column: string
  • operator: string
  • value: any

Returns

this

gt

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

gte

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

ilike

method
(column: string, pattern: string) => this

Parameters

  • column: string
  • pattern: string

Returns

this

imatch

method

Case-insensitive regex match (~*)

(column: string, pattern: string) => this

Parameters

  • column: string
  • pattern: string

Returns

this

in

method
(column: string, values: any[]) => this

Parameters

  • column: string
  • values: any[]

Returns

this

insert

method

Insert one row or many. Returns the inserted rows by default.

(data: Record<string, any> | Record<string, any>[], options?: { defaultToNull?: boolean }) => this

Parameters

  • data: Record<string, any> | Record<string, any>[]
  • options?: { defaultToNull?: boolean }

Returns

this

Examples

await linabase.from("posts").insert({ title: "Hi" });
await linabase.from("posts").insert([{ title: "A" }, { title: "B" }]);

is

method
(column: string, value: boolean | "null" | "true" | "false" | null) => this

Parameters

  • column: string
  • value: boolean | "null" | "true" | "false" | null

Returns

this

isDistinct

method

IS DISTINCT FROM

(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

like

method
(column: string, pattern: string) => this

Parameters

  • column: string
  • pattern: string

Returns

this

limit

method
(count: number) => this

Parameters

  • count: number

Returns

this

limitForeignTable

method

Limit results on a foreign table

(count: number, foreignTable: string) => this

Parameters

  • count: number
  • foreignTable: string

Returns

this

lt

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

lte

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

match

method

Regex match (~) when called with (column, pattern). Object-based multi-column filter when called with ({ col: val }).

(columnOrFilter: string | Record<string, any>, pattern?: string) => this

Parameters

  • columnOrFilter: string | Record<string, any>
  • pattern?: string

Returns

this

maybeSingle

method

Return a single object or null. Errors only if >1 rows.

() => this

Returns

this

neq

method
(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

not

method

Negate a filter: not.eq, not.in, not.is, etc.

(column: string, operator: string, value: any) => this

Parameters

  • column: string
  • operator: string
  • value: any

Returns

this

offset

method
(count: number) => this

Parameters

  • count: number

Returns

this

offsetForeignTable

method

Offset results on a foreign table

(count: number, foreignTable: string) => this

Parameters

  • count: number
  • foreignTable: string

Returns

this

or

method

OR filter: or("age.gt.20,name.eq.John")

(filters: string, options?: { foreignTable?: string }) => this

Parameters

  • filters: string
  • options?: { foreignTable?: string }

Returns

this

order

method
(column: string, options?: { ascending?: boolean; foreignTable?: string; nullsFirst?: boolean }) => this

Parameters

  • column: string
  • options?: { ascending?: boolean; foreignTable?: string; nullsFirst?: boolean }

Returns

this

overlaps

method

Overlap (&&) - ranges or arrays

(column: string, value: any) => this

Parameters

  • column: string
  • value: any

Returns

this

range

method

Range-based pagination: range(0, 9) fetches the first 10 rows.

(from: number, to: number) => this

Parameters

  • from: number
  • to: number

Returns

this

rangeAdjacent

method

Range is adjacent to

(column: string, range: string) => this

Parameters

  • column: string
  • range: string

Returns

this

rangeGt

method

Strictly right of: [a,b] >> [c,d]

(column: string, range: string) => this

Parameters

  • column: string
  • range: string

Returns

this

rangeGte

method

Does not extend to the left of

(column: string, range: string) => this

Parameters

  • column: string
  • range: string

Returns

this

rangeLt

method

Strictly left of: [a,b] << [c,d]

(column: string, range: string) => this

Parameters

  • column: string
  • range: string

Returns

this

rangeLte

method

Does not extend to the right of

(column: string, range: string) => this

Parameters

  • column: string
  • range: string

Returns

this

returning

method

Specify return=minimal to skip returning data on mutations (better performance).

(mode: "minimal" | "representation") => this

Parameters

  • mode: "minimal" | "representation"

Returns

this

schema

method

Switch schema. Sets Accept-Profile (GET) or Content-Profile (POST/PATCH/DELETE).

(schemaName: string) => this

Parameters

  • schemaName: string

Returns

this

select

method

Pick which columns to return. Supports nested joins (`"*, comments(*)"`) and column aliases (`"full_name:name"`). When chained after a mutation (`insert` / `update` / `upsert` / `delete`), it switches the request to `Prefer: return=representation` so the modified rows come back.

(columns?: string, options?: { count?: "exact" | "estimated" | "planned"; head?: boolean }) => this

Parameters

  • columns?: stringPostgres-style column list. Defaults to `"*"`.
  • options?: { count?: "exact" | "estimated" | "planned"; head?: boolean }`count` returns a row count alongside the data; `head` omits the rows entirely (useful for count-only queries).

Returns

this

Examples

await linabase.from("posts").select("id, title");
await linabase.from("posts").select("*, author:profiles(name)");
await linabase.from("posts").select("*", { count: "exact", head: true });

single

method

Return a single object instead of an array. Errors if 0 or >1 rows.

() => this

Returns

this

textSearch

method

Full-text search (to_tsquery, plainto_tsquery, phraseto_tsquery, or websearch_to_tsquery)

(column: string, query: string, options?: { config?: string; type?: "plain" | "phrase" | "websearch" }) => this

Parameters

  • column: string
  • query: string
  • options?: { config?: string; type?: "plain" | "phrase" | "websearch" }

Returns

this

then

method

Makes DatabaseClient thenable (await-able). Resolves to `{ data, error, count }` where data is permissively typed so callers can access properties without generated database types.

(onfulfilled?: (value: any) => T | PromiseLike<T> | null, onrejected?: (reason: any) => U | PromiseLike<U> | null) => Promise<T | U>

Parameters

  • onfulfilled?: (value: any) => T | PromiseLike<T> | null
  • onrejected?: (reason: any) => U | PromiseLike<U> | null

Returns

Promise<T | U>

throwOnError

method

Throw an error instead of returning it in the result object.

() => this

Returns

this

update

method

Update rows that match the active filters.

(data: Record<string, any>) => this

Parameters

  • data: Record<string, any>

Returns

this

Examples

await linabase
  .from("posts")
  .update({ published: true })
  .eq("id", 42);

upsert

method

Upsert: insert or update on conflict. Uses merge-duplicates by default.

(data: Record<string, any> | Record<string, any>[], options?: { defaultToNull?: boolean; ignoreDuplicates?: boolean; onConflict?: string }) => this

Parameters

  • data: Record<string, any> | Record<string, any>[]
  • options?: { defaultToNull?: boolean; ignoreDuplicates?: boolean; onConflict?: string }

Returns

this

FunctionsClient

class

Invoke server-side functions registered with the project. Exposed via `linabase.functions`. The auth token, when set, is forwarded automatically so the function can identify the calling user.

Examples

const { data, error } = await linabase.functions.invoke("send-welcome", {
  body: { userId: user.id },
});

invoke

method

Call a function by name.

(name: string, options?: FunctionInvokeOptions) => Promise<{ data: T | null; error: any }>

Parameters

  • name: stringFunction slug as registered on the project.
  • options?: FunctionInvokeOptionsBody, method, and optional extra headers.

Returns

Promise<{ data: T | null; error: any }>`{ data, error }` — `data` is the parsed JSON response, `error` is an object with `message` if the call failed (HTTP non-2xx or thrown).

Examples

await linabase.functions.invoke("ping");

RpcClient

class

call

method

Call a Postgres function: rpc("my_function", { arg1: "value" }, { count: "exact" })

(fn: string, args?: Record<string, any>, options?: { count?: "exact" | "estimated" | "planned"; throwOnError?: boolean }) => Promise<QueryResult<any>>

Parameters

  • fn: string
  • args?: Record<string, any>
  • options?: { count?: "exact" | "estimated" | "planned"; throwOnError?: boolean }

Returns

Promise<QueryResult<any>>

StorageClient

class

S3-compatible storage API for a project. Exposed via `linabase.storage`. Provides bucket management at the top level; per-bucket file operations live on BucketClient, accessed via `linabase.storage.from("bucket-name")`.

Examples

// Top-level bucket management
await linabase.storage.createBucket("avatars", { public: true });
const { data: buckets } = await linabase.storage.listBuckets();

// File operations on a bucket
await linabase.storage.from("avatars").upload("alice.png", file);

createBucket

method
(name: string, options?: { public?: boolean }) => Promise<{ data: any; error: any }>

Parameters

  • name: string
  • options?: { public?: boolean }

Returns

Promise<{ data: any; error: any }>

from

method
(bucket: string) => BucketClient

Parameters

  • bucket: string

Returns

BucketClient

listBuckets

method
() => Promise<{ data: any[]; error: any }>

Returns

Promise<{ data: any[]; error: any }>

Interfaces

AuthSession

interface

access_token

property
string

expires_at

property
number

expires_in

property
number

refresh_token

property
string

token_type

property
string

user

property
AuthUser

AuthUser

interface

created_at

property
string

email

property
string | null

email_confirmed_at

property
string | null

id

property
string

raw_app_meta_data

property
Record<string, unknown>

raw_user_meta_data

property
Record<string, unknown>

role

property
string

updated_at

property
string

user_metadata

property

Alias for raw_user_meta_data (Supabase compatibility)

Record<string, unknown>

CsvQueryResult

interface

count

property
number | null

data

property
string | null

error

property
PostgrestError | null

FunctionInvokeOptions

interface

Options for FunctionsClient.invoke.

body

property

JSON body for POST, or query parameters for GET.

Record<string, any>

headers

property

Extra request headers (merged with auth headers).

Record<string, string>

method

property

HTTP method. Defaults to `POST`.

"GET" | "POST"

LinabaseClient

interface

The Linabase client. Returned by createClient. Combines query, auth, storage, and function-invocation APIs behind a single object. Most apps create one client per project at startup and reuse it everywhere.

auth

property

User auth: sign in, sign up, sessions, OAuth, admin operations.

AuthClient

branch

property

Returns a new client that targets the given branch via X-Branch header.

(slug: string) => LinabaseClient

channel

property

Realtime channel (stub; not yet supported). Returns a chainable no-op.

(name: string) => any

from

property

Start a query against a table in the project's `public` schema.

(table: string) => DatabaseClient

functions

property

Invoke server-side functions.

FunctionsClient

generateTypes

property

Generate TypeScript types for the project's database schema.

() => Promise<string>

removeChannel

property

Remove a realtime channel (stub; not yet supported).

(channel: any) => void

rpc

property

Call a Postgres function (RPC).

(fn: string, args?: Record<string, any>) => Promise<QueryResult<any>>

schema

property

Target a non-default schema (`auth`, `storage`, etc.) for the next query.

(schemaName: string) => { from: (table: string) => DatabaseClient }

storage

property

S3-compatible object storage for the project.

StorageClient

LinabaseConfig

interface

anonKey

property
string

auth

property

Persistent storage for auth sessions (e.g., AsyncStorage for React Native).

{ detectSessionInUrl?: boolean; persistSession?: boolean; storage?: SessionStorage; storageKey?: string }

branch

property

Optional: target a specific DB branch for the entire lifetime of the client. When set, every request carries an `X-Branch: {slug}` header so the REST API routes it to the branch schemas. Equivalent to calling `.branch(slug)` on the returned client, except it applies to the root client directly. Leave unset (the default) to use the main project schemas.

string

serviceRoleKey

property
string

url

property
string

PostgrestError

interface

code

property
string

details

property
string

hint

property
string

message

property
string

QueryResult

interface

count

property
number | null

data

property
T[] | null

error

property
PostgrestError | null

SessionStorage

interface

Minimal async key-value storage interface (compatible with AsyncStorage, localStorage, etc.)

getItem

method
(key: string) => string | Promise<string | null> | null

Parameters

  • key: string

Returns

string | Promise<string | null> | null

removeItem

method
(key: string) => void | Promise<void>

Parameters

  • key: string

Returns

void | Promise<void>

setItem

method
(key: string, value: string) => void | Promise<void>

Parameters

  • key: string
  • value: string

Returns

void | Promise<void>

SingleQueryResult

interface

count

property
number | null

data

property
T | null

error

property
PostgrestError | null

Functions

createClient

function

Create a Linabase client for a project. The client is the single entry point to the SDK. Every query, auth call, and storage operation goes through it. The same instance can be reused across the app; it tracks the user's session internally.

(config: LinabaseConfig) => LinabaseClient

Parameters

  • config: LinabaseConfigConnection details. `url` is the project's Linabase API URL, and `anonKey` is the public API key (safe to ship in frontend bundles). Use `serviceRoleKey` only on a trusted server.

Returns

LinabaseClientA LinabaseClient instance.

Examples

import { createClient } from "@linabase/js";

const linabase = createClient({
  url: "https://linabase.com",
  anonKey: "lb_anon_...",
});

const { data, error } = await linabase
  .from("posts")
  .select("*, author:profiles(name)")
  .eq("published", true);

Type Aliases

OAuthProvider

typeAlias
"google" | "github" | "apple" | "microsoft" | "linkedin" | "slack" | "gitlab" | "bitbucket" | "discord" | "facebook" | "twitter" | "reddit" | "twitch" | "tiktok" | "spotify" | "telegram" | "roblox"