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
- JavaScript
- Dart/Flutter
- Swift
- Kotlin
- Java
- C#
- C++
import { createClient } from '@edgebase/web';
const client = createClient('https://my-app.edgebase.fun');
import 'package:edgebase_flutter/edgebase.dart';
final client = ClientEdgeBase('https://my-app.edgebase.fun');
import EdgeBase
let client = EdgeBaseClient("https://my-app.edgebase.fun")
import dev.edgebase.sdk.client.ClientEdgeBase
val client = ClientEdgeBase("https://my-app.edgebase.fun")
import dev.edgebase.sdk.client.ClientEdgeBase;
import dev.edgebase.sdk.client.EdgeBase;
ClientEdgeBase client = EdgeBase.client("https://my-app.edgebase.fun");
using EdgeBase;
var client = new EdgeBase("https://my-app.edgebase.fun");
#include <edgebase/edgebase.h>
client::EdgeBase client("https://my-app.edgebase.fun");
Basic Calls
- JavaScript
- Dart/Flutter
- Swift
- Kotlin
- Java
- C#
- C++
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');
final result = await client.functions.post('send-email', {
'to': 'user@example.com',
'subject': 'Welcome!',
});
final users = await client.functions.get('users');
await client.functions.delete('users/abc123');
let result = try await client.functions.post("send-email", body: [
"to": "user@example.com",
"subject": "Welcome!",
])
let users = try await client.functions.get("users")
try await client.functions.delete("users/abc123")
val result = client.functions.post("send-email", mapOf(
"to" to "user@example.com",
"subject" to "Welcome!"
))
val users = client.functions.get("users")
client.functions.delete("users/abc123")
var result = client.functions().post("send-email", Map.of(
"to", "user@example.com",
"subject", "Welcome!"
));
var users = client.functions().get("users");
client.functions().delete("users/abc123");
var result = await client.Functions.PostAsync("send-email", new {
to = "user@example.com",
subject = "Welcome!"
});
var users = await client.Functions.GetAsync("users");
await client.Functions.DeleteAsync("users/abc123");
auto result = client.functions().post(
"send-email",
R"({"to":"user@example.com","subject":"Welcome!"})"
);
auto users = client.functions().get("users");
client.functions().del("users/abc123");
Generic Call
- JavaScript
- Dart/Flutter
- Swift
- Kotlin
- Java
- C#
- C++
const result = await client.functions.call('my-function', {
method: 'PUT',
body: { name: 'Updated' },
});
final result = await client.functions.call(
'my-function',
options: const FunctionCallOptions(
method: 'PUT',
body: {'name': 'Updated'},
),
);
let result = try await client.functions.call(
"my-function",
options: FunctionCallOptions(
method: "PUT",
body: ["name": "Updated"]
)
)
val result = client.functions.call(
"my-function",
FunctionCallOptions(
method = "PUT",
body = mapOf("name" to "Updated")
)
)
var result = client.functions().call(
"my-function",
new FunctionsClient.FunctionCallOptions(
"PUT",
Map.of("name", "Updated"),
null
)
);
var result = await client.Functions.CallAsync("my-function", new FunctionCallOptions {
Method = "PUT",
Body = new { name = "Updated" }
});
auto result = client.functions().call(
"my-function",
"PUT",
R"({"name":"Updated"})"
);
Authentication
If the user is signed in, the SDK sends the auth token automatically.
- JavaScript
- Dart/Flutter
- Swift
- Kotlin
- Java
- C#
- C++
await client.auth.signIn({ email: 'user@test.com', password: 'pass123' });
const profile = await client.functions.get('me/profile');
await client.auth.signIn(
email: 'user@test.com',
password: 'pass123',
);
final profile = await client.functions.get('me/profile');
try await client.auth.signIn(
email: "user@test.com",
password: "pass123"
)
let profile = try await client.functions.get("me/profile")
client.auth.signIn(
email = "user@test.com",
password = "pass123"
)
val profile = client.functions.get("me/profile")
client.auth().signIn("user@test.com", "pass123");
Object profile = client.functions().get("me/profile");
await client.Auth.SignInAsync("user@test.com", "pass123");
var profile = await client.Functions.GetAsync("me/profile");
client.auth().signIn("user@test.com", "pass123");
auto profile = 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.statusanderr.codeare aliases for the HTTP status code.status === 0means a transport-level failure rather than a semantic App Function error response.- Server-side
FunctionError('permission-denied', ...)becomes an SDK error with HTTP status403,unauthenticatedbecomes401, and so on. - For business-rule failures, branch on HTTP status. For retries, treat
status === 0and503as transient first.
Notes
- React Native uses the same
functionsAPI 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/*.