userland Sign in Menu

Reference

Native Worker runtime

Standard Worker handlers and native bindings.

For agents: Discover current capabilities, preserve exact operation identities, and follow the native workflow.

Native apps export a standard Cloudflare Worker. They do not receive a Userland runtime context or use a Userland runtime SDK.

export default {
  async fetch(request, env, executionContext) {
    const rows = await env.DB.prepare("SELECT id, title FROM notes LIMIT 20").all();
    return Response.json(rows.results);
  }
};

env contains the app’s declared and resolved bindings. Use D1 SQL, private R2 objects, static assets and secret bindings directly when the current Account supports them. Userland resolves owned resource identities; app code does not receive Userland or Cloudflare management credentials.

App security

The app owns its sign-in, sessions, record permissions and error responses. Use host-only __Host- cookies with Secure, HttpOnly and Path=/, reject ambiguous duplicates, and check exact Origin on state changes. Check the authenticated user’s access to every record and file. See Auth.

Execution boundaries

The gateway enforces admission, preview access and shared-host isolation. A private preview grant is removed before the request reaches app code. An app must still authorize its own users. Streams and WebSockets preserve runtime behavior, but an already admitted execution can outlive an execution stop.

Use console for carefully chosen diagnostics when observability is enabled. Never log credentials or private request bodies. Runtime logs are untrusted, may be redacted or incomplete, and require full publishing access. See App diagnostics.

The native-notes reference demonstrates Worker code, D1 migrations, private R2 attachments and app-owned sessions without a platform runtime dependency.

Userland docsYours, live.