Skip to main content

Client SDK

Beta

This feature is in beta. Core behavior is stable, but some APIs or configuration may change before general availability.

Call App Functions from the client SDK with auth headers injected automatically.

client.functions is a hand-written helper surface. It is consistent across SDKs, but unlike the generated REST core, it is not produced directly from OpenAPI.

Supported Client SDKs

  • JavaScript (@edgebase/web)
  • React Native (@edgebase/react-native)
  • Dart / Flutter
  • Swift
  • Kotlin
  • Java
  • C#
  • C++

Setup

import { createClient } from '@edgebase/web';

const client = createClient('https://my-app.edgebase.fun');

Basic Calls

const result = await client.functions.post('send-email', {
to: 'user@example.com',
subject: 'Welcome!',
});

const users = await client.functions.get('users');
await client.functions.delete('users/abc123');

Generic Call

const result = await client.functions.call('my-function', {
method: 'PUT',
body: { name: 'Updated' },
});

Authentication

If the user is signed in, the SDK sends the auth token automatically.

await client.auth.signIn({ email: 'user@test.com', password: 'pass123' });
const profile = await client.functions.get('me/profile');

Server function:

export const GET = defineFunction(async ({ auth, admin }) => {
if (!auth) throw new FunctionError('unauthenticated', 'Login required');
return admin.db('app').table('profiles').get(auth.id);
});

Error Handling

App Function failures are surfaced through the SDK as EdgeBaseError.

import { EdgeBaseError } from '@edgebase/web';

try {
await client.functions.post('orders', { items: [] });
} catch (err) {
if (err instanceof EdgeBaseError) {
if (err.status === 0) {
// The SDK did not receive a usable HTTP response.
retryLater();
return;
}

if (err.status === 401) {
redirectToLogin();
return;
}

showError(err.message);
}
}

Practical rules:

  • err.status and err.code are aliases for the HTTP status code.
  • status === 0 means a transport-level failure rather than a semantic App Function error response.
  • Server-side FunctionError('permission-denied', ...) becomes an SDK error with HTTP status 403, unauthenticated becomes 401, and so on.
  • For business-rule failures, branch on HTTP status. For retries, treat status === 0 and 503 as transient first.

Notes

  • React Native uses the same functions API shape as the web SDK.
  • C++ uses JSON strings for request bodies instead of language-level map serialization helpers.
  • Function routes are always resolved under /api/functions/*.