Skip to content

JavaScript SDK

CURRENT · 0.2.2

@opencloud/js is an ESM browser client for OpenCloud applications. It is currently distributed by the platform itself rather than the npm registry.

Load it

Recommended runtime discovery:

js
const runtime = await fetch("/_opencloud/config").then((response) =>
  response.json(),
);
const { createOpenCloudClient } = await import(
  runtime.javascriptSdk.module
);
const opencloud = createOpenCloudClient();

Exact pinned import:

js
import {
  createOpenCloudClient,
} from "/_opencloud/sdk/js/v0.2.2/index.js";

TypeScript declarations are available at:

text
/_opencloud/sdk/js/v0.2.2/index.d.ts

The source and declarations are versioned in the OpenCloud platform repository. For a compact list of every public method, open the JavaScript SDK API reference.

Namespaces

NamespacePurpose
config()App identity, origins, Storage bucket, and exact SDK metadata
session()Safe user profile and expiry timestamps; never returns tokens
rest.request()Authenticated or anonymous PostgREST requests
storage.request()Authenticated Storage requests
functions.invoke()JWT-protected Function requests
functions.invokePublic()Deliberately public Function requests
realtime.channel()Private broadcast channels with reconnect and heartbeat
telemetry.summary()Safe host-bound activity and usage aggregate
telemetry.increment()Emit a declared bounded counter
telemetry.gauge()Emit a declared bounded gauge
dispose()Stop session refresh and release client state

There is no opencloud.functions.request, channel.on, or channel.subscribe. Use only the methods documented here.

Security model

The SDK reads an opaque HttpOnly broker cookie indirectly through /_opencloud/session. Access tokens stay inside the SDK and are refreshed before expiry. The public session() result never contains access or refresh tokens.

Self-hosted infrastructure for agent-built applications.