Cloudflare API
Generated public TypeScript reference for @relkit/cloudflare.
For configuration and examples, read integrations, providers.
Public imports
@relkit/cloudflare— 6 exports@relkit/cloudflare/runtime— 6 exports
All exported APIs
Names link to their complete contracts. Re-exports share their original contract; legacy exports keep their separate identity. Examples link to the API’s inline sample, a maintained repository usage, or the shared module walkthrough.
| API | Kind | Import from | Example |
|---|---|---|---|
| CloudflareKvAdapter | Type | @relkit/cloudflare |
Module example |
| CloudflareKvCacheOptions | Type | @relkit/cloudflare/runtime |
Module example |
| CloudflareKvCacheProvider | Type | @relkit/cloudflare/runtime |
Module example |
| CloudflareKvOptions | Type | @relkit/cloudflare |
Module example |
| CloudflareR2Adapter | Type | @relkit/cloudflare |
Module example |
| CloudflareR2BucketOptions | Type | @relkit/cloudflare/runtime |
Module example |
| CloudflareR2Options | Type | @relkit/cloudflare |
Module example |
| createCloudflareKvCacheProvider | Value | @relkit/cloudflare/runtime |
Module example |
| createCloudflareR2BucketProvider | Value | @relkit/cloudflare/runtime |
Module example |
| kv | Value | @relkit/cloudflare |
Source example |
| r2 | Value | @relkit/cloudflare |
Source example |
| runtimeIntegration | Value | @relkit/cloudflare/runtime |
Module example |
cloudflare.ts
kv
Defines a connected Cloudflare Workers KV cache.
Signature
declare const kv: (options: CloudflareKvOptions) => CloudflareKvAdapter;
Since v0.2.0
r2
Defines a connected Cloudflare R2 bucket through its S3-compatible API.
Signature
declare const r2: (options: CloudflareR2Options) => CloudflareR2Adapter;
Since v0.2.0
CloudflareKvAdapter (type alias)
Signature
type CloudflareKvAdapter = ProviderAdapter<
typeof cache,
"cloudflare-kv",
ProviderConnectionValues,
ProviderBehavior<Readonly<{ minimumTtlMs: 60_000 }>>
>;
CloudflareKvOptions (interface)
Signature
export interface CloudflareKvOptions {
readonly accountId: TextValue;
readonly namespaceId: TextValue;
readonly apiToken: SecretReference;
}
CloudflareR2Adapter (type alias)
Signature
type CloudflareR2Adapter = ProviderAdapter<
typeof bucket,
"cloudflare-r2",
ProviderConnectionValues,
ProviderBehavior<Readonly<{ signedUrlTtlSeconds: number }>>
>;
CloudflareR2Options (interface)
Signature
export interface CloudflareR2Options {
readonly accountId: TextValue;
readonly bucketName: TextValue;
readonly credentials: Readonly<{
accessKeyId: SecretReference;
secretAccessKey: SecretReference;
}>;
readonly signedUrlTtlSeconds?: number;
}
index.ts
“./cloudflare.js” (namespace export)
Re-exports all named exports from the “./cloudflare.js” module.
Signature
export * from "./cloudflare.js";
index.ts
“./kv.js” (namespace export)
Re-exports all named exports from the “./kv.js” module.
Signature
export * from "./kv.js";
“./r2.js” (namespace export)
Re-exports all named exports from the “./r2.js” module.
Signature
export * from "./r2.js";
runtimeIntegration
Signature
declare const runtimeIntegration: Readonly<{
kind: "runtime-integration";
integrationId: "cloudflare";
registrations: ReadonlyArray<
| {
capability: string;
adapterId: string;
protocolVersion: number;
create: ({ connection, behavior }: RuntimeProviderContext) => { value: BucketProvider };
}
| {
capability: string;
adapterId: string;
protocolVersion: number;
create: ({ profile, connection }: RuntimeProviderContext) => {
value: CloudflareKvCacheProvider;
ready: () => Promise<void>;
release: () => Promise<void>;
};
}
>;
}>;
kv.ts
CloudflareKvCacheOptions (interface)
Signature
export interface CloudflareKvCacheOptions {
readonly accountId: string;
readonly namespaceId: string;
readonly apiToken: string;
readonly cacheId: string;
readonly fetch?: typeof globalThis.fetch;
}
CloudflareKvCacheProvider (interface)
Signature
export interface CloudflareKvCacheProvider extends CacheProvider {
readonly ready: () => Promise<void>;
readonly close: () => Promise<void>;
}
createCloudflareKvCacheProvider
Signature
declare const createCloudflareKvCacheProvider: (
options: CloudflareKvCacheOptions,
) => CloudflareKvCacheProvider;
r2-signing.ts
R2Credentials (interface)
Signature
export interface R2Credentials {
readonly accessKeyId: string;
readonly secretAccessKey: string;
}
R2RequestInit (type alias)
Signature
type R2RequestInit = Omit<RequestInit, "body"> & {
readonly body?: string | Uint8Array | null;
};
assertR2Response
Signature
declare const assertR2Response: (response: Response, operation: string) => Promise<Response>;
presignR2Url
Signature
declare const presignR2Url: (
url: string,
method: "GET" | "PUT",
credentials: R2Credentials,
expiresSeconds: number,
) => Promise<string>;
signedR2Request
Signature
declare const signedR2Request: (
url: string,
credentials: R2Credentials,
init?: R2RequestInit,
fetcher?: typeof globalThis.fetch,
) => Promise<Response>;
r2.ts
CloudflareR2BucketOptions (interface)
Signature
export interface CloudflareR2BucketOptions extends R2Credentials {
readonly accountId: string;
readonly bucketName: string;
readonly signedUrlTtlSeconds?: number;
readonly fetch?: typeof globalThis.fetch;
}
createCloudflareR2BucketProvider
Signature
declare const createCloudflareR2BucketProvider: (
options: CloudflareR2BucketOptions,
) => BucketProvider;