Expand description
Access Cloudflare Worker bindings and request context from inside
#[server] functions.
§Binding shortcuts
cf::d1()— D1 database (combines env + binding lookup + error conversion)cf::kv()— Workers KV namespacecf::r2()— R2 bucketcf::durable_object()— Durable Object namespace- [
cf::queue()] — Queue producer (requiresqueuefeature)
§Raw access
cf::env()— the full WorkerEnv(for bindings without a shorthand)cf::req()— the rawworker::Request(headers, IP)
§Incoming cookies
cf::cookie()— read a named cookie from the requestcf::cookies()— read all cookies from the request
§Outgoing cookies
cf::set_cookie()— queue an HttpOnly auth cookie (secure defaults)cf::set_cookie_with()— queue a cookie with custom optionscf::clear_cookie()— queue a cookie-clearing header (logout)
Outgoing cookies are queued in thread-local storage and applied to the
response by handle — no &mut Response needed inside server functions.
Structs§
- Cookie
Builder - Builder for cookies with custom options.
Enums§
- Same
Site SameSiteattribute for cookies.
Functions§
- clear_
cookie - Queue a cookie-clearing header on the outgoing response (
Max-Age=0). - cookie
- Read a named cookie from the incoming request’s
Cookieheader. - cookies
- Read all cookies from the incoming request’s
Cookieheader. - d1
- Access a D1 database binding by name.
- durable_
object - Access a Durable Object namespace binding by name.
- env
- Access the Cloudflare Worker
Envfrom inside any#[server]function. - kv
- Access a Workers KV namespace binding by name.
- r2
- Access an R2 bucket binding by name.
- req
- Access the raw Cloudflare Worker
worker::Requestfor the current request. - set_
cookie - Queue an
HttpOnlyauth cookie on the outgoing response. - set_
cookie_ with - Start building a cookie with custom options.