Cloudflare Workers

Rakkas projects can be deployed to Cloudflare Workers. First, you should install the suitable HatTip adapter:

npm install -S @hattip/adapter-cloudflare-workers

Then you should set the adapter option of Rakkas Vite plugin to "cloudflare-workers":

import { defineConfig } from "vite";
import rakkas from "rakkasjs/vite-plugin";

export default defineConfig({
	plugins: [
			adapter: "cloudflare-workers",

Then create a wrangler.toml file like this:

name = "my-rakkas-project"
compatibility_date = "2021-11-01"
compatibility_flags = [
main = "dist/server/cloudflare-workers-bundle.js"
usage_model = 'bundled'
workers_dev = true

bucket = "./dist/client"

After building with rakkas build, you can publish your project with wrangler publish. You can also test locally with miniflare --modules dist/server/cloudflare-workers-bundle.js.

Cloudflare Workers-specific APIs

During development, Rakkas applications always run on Node.js regardless of the adapter setting. As such, Cloudflare Workers-specific APIs like the KV store and durable objects are not available. You can polyfill them using, e.g., @miniflare/kv and @miniflare/durable-objects packages in a custom Node.js entry.