
Product
Introducing Socket Fix for Safe, Automated Dependency Upgrades
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
@hattip/adapter-cloudflare-workers
Advanced tools
@hattip/adapter-cloudflare-workers
Hattip adapter for Cloudflare Workers.
Assuming you have your Hattip handler defined in handler.js
, create an entry file like the following and use @hattip/bundler-cloudflare-workers
or your favorite bundler to bundle it:
import cloudflareWorkersAdapter from "@hattip/adapter-cloudflare-workers";
import handler from "./handler.js";
export default {
fetch: cloudflareWorkersAdapter(handler),
};
If you don't need to serve static files, you can import the adapter from @hattip/adapter-cloudflare-workers/no-static
instead. You will get an error if you use the default adapter but you don't set up site = { bucket = "<YOUR STATIC FILES DIR>" }
in your wrangler.toml
.
@hattip/adapter-cloudflare-workers
uses the newer modules format instead of the service worker format.
context.platform
export interface CloudflareWorkersPlatformInfo {
/** Platform name */
name: "cloudflare-workers";
/**
* Bindings for secrets, environment variables, and other resources like
* KV namespaces etc.
*/
env: unknown;
/**
* Execution context
*/
context: ExecutionContext;
}
The ctx.env()
function only returns bindings with a string value. Such bindings correspond to secrets and environment variables. Other bindings like KV or D1 will return undefined
. You should use ctx.platform.env
to access them instead.
FAQs
Cloudflare Workers adapter for Hattip
The npm package @hattip/adapter-cloudflare-workers receives a total of 588 weekly downloads. As such, @hattip/adapter-cloudflare-workers popularity was classified as not popular.
We found that @hattip/adapter-cloudflare-workers demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Automatically fix and test dependency updates with socket fix—a new CLI tool that turns CVE alerts into safe, automated upgrades.
Security News
CISA denies CVE funding issues amid backlash over a new CVE foundation formed by board members, raising concerns about transparency and program governance.
Product
We’re excited to announce a powerful new capability in Socket: historical data and enhanced analytics.