JavaScript SDK
CURRENT · 2.3.0
@opencloud/js is the same-origin browser SDK for OpenCloud apps. Import the deployment-pinned singleton from the stable path:
js
import { opencloud, OpenCloudError } from "/_opencloud/sdk.js";Do not install the package, fetch runtime config, construct a client, or import a versioned artifact. OpenCloud maps the stable module and /_opencloud/sdk.d.ts declarations to runtime.sdk.version for the active release.
Public surface
| Namespace | Methods |
|---|---|
| version | OPEN_CLOUD_SDK_VERSION |
app | info() |
auth | currentUser(), requireUser(), signInUrl() |
data.table(name) | list(), getById(), create(), createMany(), updateById(), deleteById() |
files | upload(), info(), download(), save(), replace(), remove(), attach() |
functions | call(), stream() |
notifications | status(), subscribe(), unsubscribe() |
realtime | subscribe(), publish() |
telemetry | summary(), increment(), gauge() |
| client | dispose() |
The methods return application values, opaque file metadata, typed errors, or a byte stream. Raw Response objects, REST paths, Storage buckets, Function auth modes, access tokens, and Realtime protocol envelopes are intentionally not public.
A complete small flow
js
import { opencloud } from "/_opencloud/sdk.js";
await opencloud.auth.requireUser();
const tasks = opencloud.data.table("tasks");
const task = await tasks.create({ title: "Review evidence" });
const { file } = await opencloud.files.attach({
data: selectedFile,
name: selectedFile.name,
table: "task_files",
values: { task_id: task.id },
});
const result = await opencloud.functions.call("summarize", {
taskId: task.id,
fileId: file.id,
});Read Client and Auth, Data and Files, Functions, Realtime, Telemetry, Notifications, and Errors before using each capability.
