worktop is a lightweight, high-performance web framework designed for edge computing environments. While originally focused on Cloudflare Workers, versions `0.8.0-next.x` are evolving towards platform agnosticism, supporting Cloudflare Workers, Service Workers (web), and Deno, with future plans for Node.js. The current stable release is `0.7.3`, but active development is ongoing in the `0.8.0-next` series, which introduces significant breaking changes and module restructuring to support its multi-runtime strategy. It differentiates itself by providing a minimal core API that adheres to Web Standards, offering a highly efficient router and specialized submodules for platform-specific features like KV storage and WebSockets, ensuring optimal performance in serverless and edge environments.
npm install worktopVerified import paths — ran on the pinned version, not inferred.
This example sets up a basic `worktop` router with a dynamic GET endpoint and a catch-all route for Cloudflare Workers, demonstrating parameter extraction and static asset serving for Pages.
Review the `0.8.0-next.x` changelogs carefully. Migrate Cloudflare-specific imports to their new `worktop/cfw.*` paths. Adapt to the new `listen` entry point for handling requests. Refer to the official `worktop` documentation for the `0.8.x` branch.
Update route definitions to reflect the new `regexparam` behavior. Access wildcard values using `context.params['*']` instead of `context.params.wild`.
Ensure all data stored via `worktop/cfw.kv` `Entity` instances is valid JSON. Convert non-JSON data types to JSON-serializable formats before persisting them.
Upgrade to `worktop@0.8.0-next.15` or later to ensure proper type definitions for these standard Web APIs in Cloudflare Workers environments. Alternatively, manually declare global types if an upgrade is not immediately possible.
Ensure you are importing `Router` correctly with `import { Router } from 'worktop'` and then instantiating it with `const API = new Router();`. For older versions, check the specific import paths and usage patterns.Update your Cloudflare Workers deployment to use a recent compatibility date in `wrangler.toml` that enables `structuredClone`. If running in a different environment, ensure it provides the `structuredClone` global or polyfill it if feasible and necessary for your application logic.
Access wildcard route parameters using `context.params['*']` instead of `context.params.wild`. For example, `const value = context.params['*']`.
No dependency data recorded yet.