@supacloud/js
v0.13.0
Published
Platform SDK for SupaCloud, built on top of supabase-js
Maintainers
Readme
@supacloud/js
@supacloud/js is the platform SDK for SupaCloud.
It does not replace @supabase/supabase-js. Instead, it wraps a normal Supabase client and adds SupaCloud-specific capabilities such as:
- background task submission
- task detail and list APIs
- cancel / retry helpers
- Realtime subscription with polling fallback
- project OAuth/OIDC migration and OAuth client management
Install
npm install @supacloud/js @supabase/supabase-jsQuick Start
import { createClient } from "@supabase/supabase-js";
import { createSupaCloudClient } from "@supacloud/js";
const supabase = createClient("https://api.example.com", "anon-key");
const supacloud = createSupaCloudClient({
supabase,
managementApiUrl: "https://admin.example.com",
projectRef: "abcd1234",
});
const task = await supacloud.tasks.submit("aorist-ai/generate/crop", {
body: { image_id: "img_123" },
idempotencyKey: "crop-img_123-v1",
});
const finalState = await task.wait();
console.log(finalState.status);Design
This SDK is intentionally thin:
supabase-jsstill owns auth, storage, database, Realtime transport, and plain function invokes@supacloud/jsowns SupaCloud platform semantics layered on top of that transport
tasks.submit() expects the target function path to be configured in background_routes.
That keeps frontend calls compatible with strict CORS deployments while preserving the same task receipt API.
The current package focuses on:
tasks.submittasks.gettasks.listtasks.listDlqtasks.canceltasks.retrytasks.waittasks.subscribeauth.oauthServer.getStatusauth.oauthServer.migrateToOidcauth.oauthServer.getDiscoveryauth.oauthServer.getJwksauth.oauthServer.buildAuthorizeUrlauth.oauthClients.list/create/get/update/delete/regenerateSecret
Status Subscription
tasks.subscribe() uses this strategy:
- try
postgres_changesonpublic.tasks - if Realtime is unavailable, fall back to polling the management API
This lets apps degrade gracefully when websocket or channel health is transient.
OAuth/OIDC Helpers
client.auth.oauthServer is the SupaCloud SDK surface for project-scoped OAuth 2.1 / OIDC migration and discovery.
It does not take a global account scope. The SDK always sends the normal Management API Bearer token and lets the server enforce project ownership.
