FluxbaseClient
Main Fluxbase client class
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
Database | any |
_SchemaName extends string & keyof Database | any |
Constructors
Section titled “Constructors”new FluxbaseClient()
Section titled “new FluxbaseClient()”new FluxbaseClient<
Database,_SchemaName>(fluxbaseUrl,fluxbaseKey,options?):FluxbaseClient<Database,_SchemaName>
Create a new Fluxbase client instance
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
fluxbaseUrl | string | The URL of your Fluxbase instance |
fluxbaseKey | string | The anon key (JWT token with “anon” role). Generate using scripts/generate-keys.sh |
options? | FluxbaseClientOptions | Additional client configuration options |
Returns
Section titled “Returns”FluxbaseClient<Database, _SchemaName>
Example
Section titled “Example”const client = new FluxbaseClient( 'http://localhost:8080', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...', // Anon JWT token { timeout: 30000 })Advanced
Section titled “Advanced”Get Signature
Section titled “Get Signature”get http():
FluxbaseFetch
Get the internal HTTP client
Use this for advanced scenarios like making custom API calls or admin operations.
Example
Section titled “Example”// Make a custom API callconst data = await client.http.get('/api/custom-endpoint')Returns
Section titled “Returns”The internal FluxbaseFetch instance
Authentication
Section titled “Authentication”getAuthToken()
Section titled “getAuthToken()”getAuthToken():
null|string
Get the current authentication token
Returns
Section titled “Returns”null | string
The current JWT access token, or null if not authenticated
setAuthToken()
Section titled “setAuthToken()”setAuthToken(
token):void
Set a new authentication token
This updates both the HTTP client and realtime connection with the new token.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
token | null | string | The JWT access token to set, or null to clear authentication |
Returns
Section titled “Returns”void
Database
Section titled “Database”from()
Section titled “from()”from<
T>(table):QueryBuilder<T>
Create a query builder for a database table
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | any |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
table | string | The table name (can include schema, e.g., ‘public.users’) |
Returns
Section titled “Returns”QueryBuilder<T>
A query builder instance for constructing and executing queries
Example
Section titled “Example”// Simple selectconst { data } = await client.from('users').select('*').execute()
// With filtersconst { data } = await client.from('products') .select('id, name, price') .gt('price', 100) .eq('category', 'electronics') .execute()
// Insertawait client.from('users').insert({ name: 'John', email: 'john@example.com' }).execute()rpc<
T>(functionName,params?):Promise<object>
Call a PostgreSQL function (Remote Procedure Call)
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T | any |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
functionName | string | The name of the PostgreSQL function to call |
params? | Record<string, unknown> | Optional parameters to pass to the function |
Returns
Section titled “Returns”Promise<object>
Promise containing the function result or error
| Name | Type |
|---|---|
data | null | T |
error | null | Error |
Example
Section titled “Example”// Call a function without parametersconst { data, error } = await client.rpc('get_total_users')
// Call a function with parametersconst { data, error } = await client.rpc('calculate_discount', { product_id: 123, coupon_code: 'SAVE20'})schema()
Section titled “schema()”schema(
schemaName):SchemaQueryBuilder
Access a specific database schema
Use this to query tables in non-public schemas.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
schemaName | string | The schema name (e.g., ‘jobs’, ‘analytics’) |
Returns
Section titled “Returns”A schema query builder for constructing queries on that schema
Example
Section titled “Example”// Query the jobs.execution_logs tableconst { data } = await client .schema('jobs') .from('execution_logs') .select('*') .eq('job_id', jobId) .execute()
// Insert into a custom schema tableawait client .schema('analytics') .from('events') .insert({ event_type: 'click', data: {} }) .execute()admin:
FluxbaseAdmin
Admin module for instance management (requires admin authentication)
auth:
FluxbaseAuth
Authentication module for user management
functions
Section titled “functions”functions:
FluxbaseFunctions
Functions module for invoking and managing edge functions
jobs:
FluxbaseJobs
Jobs module for submitting and monitoring background jobs
management
Section titled “management”management:
FluxbaseManagement
Management module for API keys, webhooks, and invitations
realtime
Section titled “realtime”realtime:
FluxbaseRealtime
Realtime module for WebSocket subscriptions
settings
Section titled “settings”settings:
SettingsClient
Settings module for reading public application settings (respects RLS policies)
storage
Section titled “storage”storage:
FluxbaseStorage
Storage module for file operations
Realtime
Section titled “Realtime”channel()
Section titled “channel()”channel(
name,config?):RealtimeChannel
Create or get a realtime channel (Supabase-compatible)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
name | string | Channel name |
config? | RealtimeChannelConfig | Optional channel configuration |
Returns
Section titled “Returns”RealtimeChannel instance
Example
Section titled “Example”const channel = client.channel('room-1', { broadcast: { self: true }, presence: { key: 'user-123' }}) .on('broadcast', { event: 'message' }, (payload) => { console.log('Message:', payload) }) .subscribe()removeChannel()
Section titled “removeChannel()”removeChannel(
channel):Promise<"error"|"ok">
Remove a realtime channel (Supabase-compatible)
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
channel | RealtimeChannel | The channel to remove |
Returns
Section titled “Returns”Promise<"error" | "ok">
Promise resolving to status
Example
Section titled “Example”const channel = client.channel('room-1')await client.removeChannel(channel)