Cloudflare Workflows
Author native Cloudflare Workflows beside your Next.js app and operate instances from the dashboard.
Cloudflare Workflows is available to Arkor projects. Native WorkflowEntrypoint classes support durable steps, retries, sleeps and events. This is separate from Workflow SDK support
for "use workflow" and "use step".
Classes live in the same project as your Next.js app. Arkor builds them separately from the Workers serving pages. Ordinary page requests gain no Workflow lookup or execution.
Register and deploy
- Open Bindings, add a Cloudflare Workflow, and name it
JOBS. - Set Module path to
src/workflows/process.tsand Exported class toProcessWorkflow. The path is relative to the configured application root directory. - Add the class below and deploy. The binding stays Awaiting deployment until publication succeeds. A definition edit applies to the next deployment.
import { WorkflowEntrypoint, type WorkflowEvent, type WorkflowStep } from 'cloudflare:workers';
export interface Job {
name: string;
}
export class ProcessWorkflow extends WorkflowEntrypoint<{}, Job> {
async run(event: WorkflowEvent<Job>, step: WorkflowStep) {
const message = await step.do('prepare', async () => `Hello, ${event.payload.name}`);
await step.sleep('short-wait', '1 second');
const approval = await step.waitForEvent<{ approved: boolean }>('approval', {
type: 'approved',
timeout: '1 hour',
});
return { message, approved: approval.payload.approved };
}
}Native Worker, Hono and supported SSR projects use the same registration and read the binding from their Worker environment. Classes must be named exports.
Start from Next.js
Use the named accessor for a custom binding. Importing the input type does not import the class into the page Worker.
import { workflow } from '@stayingupwind/sdk';
import type { Job } from '@/workflows/process';
export async function POST(request: Request) {
const jobs = workflow<Job>('JOBS');
if (!jobs) return Response.json({ error: 'JOBS is not bound' }, { status: 503 });
const input = (await request.json()) as Job;
const instance = await jobs.create({ id: crypto.randomUUID(), params: input });
return Response.json({ id: instance.id }, { status: 202 });
}With one binding, import workflow from '@stayingupwind/sdk/workflow' is also available. The
SDK exposes create(), get() and instance status(), pause(), resume(), restart(),
terminate() and sendEvent(). Authorize application routes before allowing callers to operate
jobs. Reuse a stable ID when retrying a creation whose acknowledgement was lost.
const instance = await jobs.get(instanceId);
await instance.sendEvent({ type: 'approved', payload: { approved: true } });
const state = await instance.status();Dashboard and API
Open Workflows → Cloudflare Workflows, select production or a branch environment, and choose the binding. Workflow SDK remains a separate tab with its existing run links.
The list shows 50 instances at a time, newest first, with status filters and pagination. Details show status, times, input/output previews, errors, rollback outcome and step attempts. Load full step output only when needed; provider redaction remains intact. Moving instance pages refresh every five seconds while the tab is visible.
All team members can inspect instances. Owners and admins can start, pause, resume, restart from the beginning or a step, terminate with optional rollback, and send typed JSON events. Restart resets execution state without undoing external effects. A terminated instance cannot be resumed. If an operation receives no acknowledgement, inspect its state before retrying; another event or restart can repeat the operation.
Public API operations start at
/v1/projects/{projectId}/cloudflare-workflows/environments/{environment}/{bindingId}/instances.
A token with Cloudflare Workflows at Read inspects instances; at Read and write it
operates them. Use the opaque binding ID returned by
the binding list and an issued preview:bpe_… environment for a branch, never its branch name.
Isolation and resource compatibility
Production and branch environments have separate instances. Existing instances retain their immutable code and resource assignments when another deployment publishes. Removing a binding stops new instances immediately; existing instances retain their management and retirement behavior. Suspended projects and spend-limit pauses cannot start, resume, restart or signal work. Managers can still pause or terminate existing instances.
Steps read authorized resources from this.env. These are scoped adapters.
Durable Object getByName and deferred get(idFromName(...)) work, but converting a deferred
ID synchronously with toString() is unsupported. Do not pass those IDs to code expecting a
native namespace ID string. Resolve idFromName(name) with its asynchronous .resolve() when
you need the real native ID. Call await unique.resolve() before passing a newUniqueId() result
to get().
Before comparing deferred IDs from different bindings or jurisdictions with equals(), resolve
both IDs; two bindings can refer to the same native namespace.
Arkor currently absorbs Workflow CPU and connector overhead. The implemented provider telemetry does not supply dependable per-instance CPU billing attribution, so these costs are not charged to instances. Resources and services called by steps keep their existing prices and spend-limit checks.
See Cloudflare's Workers API and Workflow limits for current native semantics and provider limits.