> cloudflare-workers-multi-lang

Multi-language Workers development with Rust, Python, and WebAssembly. Use when building Workers in languages other than JavaScript/TypeScript, or when integrating WASM modules for performance-critical code.

fetch
$curl "https://skillshub.wtf/secondsky/claude-skills/cloudflare-workers-multi-lang?format=md"
SKILL.mdcloudflare-workers-multi-lang

Multi-Language Workers Development

Build Cloudflare Workers using Rust, Python, or WebAssembly for performance-critical operations.

Language Comparison

FeatureJavaScript/TSRustPython
StartupFastFastest (WASM)Moderate
CPU PerfGoodExcellentGood
MemoryHigherLowerHigher
Bundle SizeSmallerMediumLarger
Type SafetyOptional (TS)StrictOptional
Best ForGeneral appsCPU-intensiveData/ML

Quick Decision

Need maximum performance? → Rust/WASM
Heavy computation (crypto, image processing)? → Rust/WASM
Data processing, ML inference? → Python
General web apps? → JavaScript/TypeScript

Top 10 Multi-Lang Errors

ErrorLanguageCauseSolution
WebAssembly.instantiate() failedRustInvalid WASMCheck wasm-pack build output
Module parse failed: Unexpected tokenRustESM/CJS mismatchUse --target bundler
Cannot find modulePythonMissing depAdd to pyproject.toml
Out of memoryAllLarge WASMEnable streaming instantiation
Exceeded CPU time limitAllLong computationChunk processing
wasm-bindgen version mismatchRustDep conflictAlign versions in Cargo.toml
RuntimeError: unreachableRustPanic in WASMAdd proper error handling
TypeError: not a functionRustMissing exportAdd #[wasm_bindgen] attribute
Python worker startup timeoutPythonSlow initMinimize imports
SharedArrayBuffer not supportedAllSecurityAdd COOP/COEP headers

Rust Quick Start

# Install tools
cargo install wasm-pack

# Create project
cargo new --lib my-worker
cd my-worker

# Add to Cargo.toml
cat >> Cargo.toml << 'EOF'
[lib]
crate-type = ["cdylib"]

[dependencies]
wasm-bindgen = "0.2"
worker = "0.3"
console_error_panic_hook = "0.1"

[profile.release]
opt-level = "s"
lto = true
EOF
// src/lib.rs
use worker::*;

#[event(fetch)]
async fn fetch(req: Request, env: Env, _ctx: Context) -> Result<Response> {
    console_error_panic_hook::set_once();

    Router::new()
        .get("/", |_, _| Response::ok("Hello from Rust!"))
        .get("/compute", |_, _| {
            // CPU-intensive computation
            let result = heavy_computation();
            Response::ok(format!("Result: {}", result))
        })
        .run(req, env)
        .await
}

fn heavy_computation() -> u64 {
    (1..1_000_000).filter(|n| is_prime(*n)).count() as u64
}

fn is_prime(n: u64) -> bool {
    if n < 2 { return false; }
    (2..=(n as f64).sqrt() as u64).all(|i| n % i != 0)
}

Python Quick Start (Workers for Platforms)

# pyproject.toml
[project]
name = "my-worker"
version = "0.1.0"
requires-python = ">=3.12"
dependencies = []

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
# src/entry.py
from js import Response, Headers

async def on_fetch(request, env):
    url = request.url

    if "/compute" in url:
        result = heavy_computation()
        return Response.new(f"Result: {result}")

    return Response.new("Hello from Python!")

def heavy_computation():
    """CPU-intensive computation"""
    return sum(1 for n in range(2, 100000) if is_prime(n))

def is_prime(n):
    if n < 2:
        return False
    return all(n % i != 0 for i in range(2, int(n**0.5) + 1))

WASM Module Integration

// Load and use WASM module in TypeScript Worker
import wasmModule from './pkg/my_lib_bg.wasm';
import { init, process_data } from './pkg/my_lib';

let wasmInstance: WebAssembly.Instance;

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    // Initialize WASM once
    if (!wasmInstance) {
      wasmInstance = await WebAssembly.instantiate(wasmModule);
      init();
    }

    // Use WASM function
    const result = process_data(inputData);

    return Response.json({ result });
  },
};

When to Load References

ReferenceLoad When
references/rust-workers.mdBuilding Workers with Rust/WASM
references/python-workers.mdUsing Python on Workers for Platforms
references/wasm-integration.mdIntegrating WASM modules in any Worker

Performance Tips

  1. WASM Initialization: Cache instance, use streaming
  2. Memory: Use typed arrays for data transfer
  3. Bundle Size: Enable LTO, strip debug info
  4. Cold Starts: Keep WASM modules small
  5. Data Transfer: Minimize JS/WASM boundary crossings

See Also

  • workers-performance - General optimization techniques
  • workers-testing - Testing multi-language Workers
  • cloudflare-worker-base - Basic Workers setup

> related_skills --same-repo

> zustand-state-management

--- name: zustand-state-management description: Zustand state management for React with TypeScript. Use for global state, Redux/Context API migration, localStorage persistence, slices pattern, devtools, Next.js SSR, or encountering hydration errors, TypeScript inference issues, persist middleware problems, infinite render loops. Keywords: zustand, state management, React state, TypeScript state, persist middleware, devtools, slices pattern, global state, React hooks, create store, useBoundS

> zod

TypeScript-first schema validation and type inference. Use for validating API requests/responses, form data, env vars, configs, defining type-safe schemas with runtime validation, transforming data, generating JSON Schema for OpenAPI/AI, or encountering missing validation errors, type inference issues, validation error handling problems. Zero dependencies (2kb gzipped).

> xss-prevention

--- name: xss-prevention description: XSS attack prevention with input sanitization, output encoding, Content Security Policy. Use for user-generated content, rich text editors, web application security, or encountering stored XSS, reflected XSS, DOM manipulation, script injection errors. Keywords: sanitization, HTML-encoding, DOMPurify, CSP, Content-Security-Policy, rich-text-editor, user-input, escaping, innerHTML, DOM-manipulation, stored-XSS, reflected-XSS, input-validation, output-encodi

> wordpress-plugin-core

--- name: wordpress-plugin-core description: WordPress plugin development with hooks, security, REST API, custom post types. Use for plugin creation, $wpdb queries, Settings API, or encountering SQL injection, XSS, CSRF, nonce errors. Keywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql inj

┌ stats

installs/wk0
░░░░░░░░░░
github stars100
██████████
first seenApr 3, 2026
└────────────