Skip to content

FluxbaseClient

Main Fluxbase client class

Type ParameterDefault type
Databaseunknown
_SchemaName extends string & keyof Databasestring & keyof Database

new FluxbaseClient<Database, _SchemaName>(fluxbaseUrl, fluxbaseKey, options?): FluxbaseClient<Database, _SchemaName>

Create a new Fluxbase client instance

ParameterTypeDescription
fluxbaseUrlstringThe URL of your Fluxbase instance
fluxbaseKeystringThe anon key (JWT token with “anon” role). Generate using scripts/generate-keys.sh
options?FluxbaseClientOptionsAdditional client configuration options

FluxbaseClient<Database, _SchemaName>

const client = new FluxbaseClient(
'http://localhost:8080',
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', // Anon JWT token
{ timeout: 30000 }
)

get http(): FluxbaseFetch

Get the internal HTTP client

Use this for advanced scenarios like making custom API calls or admin operations.

// Make a custom API call
const data = await client.http.get('/api/custom-endpoint')

FluxbaseFetch

The internal FluxbaseFetch instance

getAuthToken(): null | string

Get the current authentication token

null | string

The current JWT access token, or null if not authenticated


setAuthToken(token): void

Set a new authentication token

This updates both the HTTP client and realtime connection with the new token.

ParameterTypeDescription
tokennull | stringThe JWT access token to set, or null to clear authentication

void

branching: FluxbaseBranching

Branching module for database branch management

Database branches allow you to create isolated copies of your database for development, testing, and preview environments.

// List all branches
const { data } = await client.branching.list()
// Create a feature branch
const { data: branch } = await client.branching.create('feature/add-auth', {
dataCloneMode: 'schema_only',
expiresIn: '7d'
})
// Reset branch to parent state
await client.branching.reset('feature/add-auth')
// Delete when done
await client.branching.delete('feature/add-auth')

from<T>(table): QueryBuilder<T>

Create a query builder for a database table

Type ParameterDefault type
Tunknown
ParameterTypeDescription
tablestringThe table name (can include schema, e.g., ‘public.users’)

QueryBuilder<T>

A query builder instance for constructing and executing queries

// Simple select
const { data } = await client.from('users').select('*').execute()
// With filters
const { data } = await client.from('products')
.select('id, name, price')
.gt('price', 100)
.eq('category', 'electronics')
.execute()
// Insert
await client.from('users').insert({ name: 'John', email: 'john@example.com' }).execute()

schema(schemaName): SchemaQueryBuilder

Access a specific database schema

Use this to query tables in non-public schemas.

ParameterTypeDescription
schemaNamestringThe schema name (e.g., ‘jobs’, ‘analytics’)

SchemaQueryBuilder

A schema query builder for constructing queries on that schema

// Query the logging.entries table
const { data } = await client
.schema('logging')
.from('entries')
.select('*')
.eq('execution_id', executionId)
.execute()
// Insert into a custom schema table
await client
.schema('analytics')
.from('events')
.insert({ event_type: 'click', data: {} })
.execute()

graphql: FluxbaseGraphQL

GraphQL module for executing queries and mutations

Provides a type-safe interface for the auto-generated GraphQL schema from your database tables.

// Execute a query
const { data, errors } = await client.graphql.query(`
query GetUsers($limit: Int) {
users(limit: $limit) {
id
email
}
}
`, { limit: 10 })
// Execute a mutation
const { data, errors } = await client.graphql.mutation(`
mutation CreateUser($data: UserInput!) {
insertUser(data: $data) {
id
email
}
}
`, { data: { email: 'user@example.com' } })

admin: FluxbaseAdmin

Admin module for instance management (requires admin authentication)


ai: FluxbaseAI

AI module for chatbots and conversation history


auth: FluxbaseAuth

Authentication module for user management


functions: FluxbaseFunctions

Functions module for invoking and managing edge functions


jobs: FluxbaseJobs

Jobs module for submitting and monitoring background jobs


management: FluxbaseManagement

Management module for client keys, webhooks, and invitations


realtime: FluxbaseRealtime

Realtime module for WebSocket subscriptions


settings: SettingsClient

Settings module for reading public application settings (respects RLS policies)


storage: FluxbaseStorage

Storage module for file operations

rpc: CallableRPC

RPC module for calling PostgreSQL functions - Supabase compatible

Can be called directly (Supabase-style) or access methods like invoke(), list(), getStatus()

// Supabase-style direct call (uses 'default' namespace)
const { data, error } = await client.rpc('get_user_orders', { user_id: '123' })
// With full options
const { data, error } = await client.rpc.invoke('get_user_orders', { user_id: '123' }, {
namespace: 'custom',
async: true
})
// List available procedures
const { data: procedures } = await client.rpc.list()

channel(name, config?): RealtimeChannel

Create or get a realtime channel (Supabase-compatible)

ParameterTypeDescription
namestringChannel name
config?RealtimeChannelConfigOptional channel configuration

RealtimeChannel

RealtimeChannel instance

const channel = client.channel('room-1', {
broadcast: { self: true },
presence: { key: 'user-123' }
})
.on('broadcast', { event: 'message' }, (payload) => {
console.log('Message:', payload)
})
.subscribe()

removeChannel(channel): Promise<"error" | "ok">

Remove a realtime channel (Supabase-compatible)

ParameterTypeDescription
channelRealtimeChannelThe channel to remove

Promise<"error" | "ok">

Promise resolving to status

const channel = client.channel('room-1')
await client.removeChannel(channel)

vector: FluxbaseVector

Vector search module for pgvector similarity search

Provides convenience methods for vector similarity search:

  • embed() - Generate embeddings from text
  • search() - Search for similar vectors with auto-embedding
// Search with automatic embedding
const { data } = await client.vector.search({
table: 'documents',
column: 'embedding',
query: 'How to use TypeScript?',
match_count: 10
})
// Generate embeddings
const { data } = await client.vector.embed({ text: 'Hello world' })

Note: For more control, use the QueryBuilder methods:

  • vectorSearch() - Filter and order by vector similarity
  • orderByVector() - Order results by vector distance